⚡ Bolt: [performance improvement] Avoid eager list materialization in AST traversal - #133
⚡ Bolt: [performance improvement] Avoid eager list materialization in AST traversal#133tachyon-beep wants to merge 1 commit into
Conversation
Updated `_assignment_callee` and `_collect_return_paths` in `src/wardline/scanner/taint/variable_level.py` to accept `Iterable[ast.AST]` instead of `list[ast.AST]`. Updated their callers to pass `ast.iter_child_nodes(node)` generators and `func_node.body` direct lists directly instead of wrapping them in `list(...)`. This avoids eagerly materializing intermediate lists, reducing memory allocation overhead. Co-authored-by: tachyon-beep <544926+tachyon-beep@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Pull request overview
This PR optimizes AST traversal in the taint scanner by avoiding unnecessary eager list materialization during recursive walks, reducing intermediate allocations and memory pressure in hot-path analysis.
Changes:
- Updated
_assignment_calleeand_collect_return_pathsto acceptIterable[ast.AST]instead oflist[ast.AST]. - Removed
list(...)wrapping aroundfunc_node.bodyandast.iter_child_nodes(...), passing iterables directly. - Added a short performance note to
.jules/bolt.mdcapturing the learning and action.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/wardline/scanner/taint/variable_level.py |
Switches traversal helpers to Iterable and removes eager list() materialization in recursive AST walking. |
.jules/bolt.md |
Documents the performance learning and recommended pattern for AST traversal. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
💡 What: Updated
_assignment_calleeand_collect_return_pathsto takeIterable[ast.AST]instead oflist[ast.AST]. Avoided eagerly wrapping generators likeast.iter_child_nodes()and standard lists likefunc_node.bodyinlist(...).🎯 Why: Creating intermediate lists during deep recursive AST walks wastes memory and time by forcing Python to allocate and populate list objects that are only used sequentially.
📊 Impact: Reduced memory pressure and allocations across recursive function body traversal.
🔬 Measurement: Verified that tests pass properly and no functionality breaks. Added a performance learning to
.jules/bolt.md.PR created automatically by Jules for task 14090105435108711551 started by @tachyon-beep