⚡ Bolt: [performance improvement] Avoid eager list materialization during AST traversal - #130
⚡ Bolt: [performance improvement] Avoid eager list materialization during AST traversal#130tachyon-beep wants to merge 1 commit into
Conversation
Modified `_assignment_callee` and `_collect_return_paths` in `src/wardline/scanner/taint/variable_level.py` to accept `Iterable[ast.AST]` instead of `list[ast.AST]`. This allows passing the result of `ast.iter_child_nodes()` directly without wrapping it in a `list()`, reducing memory allocation and overhead during deep AST traversals. 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. |
There was a problem hiding this comment.
Pull request overview
Improves AST traversal performance in the taint scanner by eliminating repeated eager list materialization during recursive walks, reducing per-node allocations and memory churn on large syntax trees.
Changes:
- Updated
_assignment_calleeand_collect_return_pathsto acceptIterable[ast.AST]and passast.iter_child_nodes(node)directly (nolist(...)copies). - Removed
list(func_node.body)materialization incompute_return_taintandcompute_return_callee. - Added a short performance note in
.jules/bolt.mddocumenting the “avoid eager list materialization” traversal guideline.
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 | Avoids eager list creation in recursive AST traversal helpers to reduce memory overhead in return-taint analysis paths. |
| .jules/bolt.md | Documents the learned performance guideline for AST traversal to prevent reintroducing eager list materialization. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
💡 What: Modified AST traversal functions
_assignment_calleeand_collect_return_pathsinsrc/wardline/scanner/taint/variable_level.pyto acceptIterable[ast.AST]instead oflist[ast.AST], removing the eagerlist()materialization ofast.iter_child_nodes(node)andfunc_node.body.🎯 Why: Eagerly converting child node generators to lists at every node during AST traversal creates unnecessary shallow copies and causes excessive memory allocation, which degrades performance especially on large or deep syntax trees.
📊 Impact: Reduces memory overhead and avoids redundant list allocations during static taint analysis traversal. By yielding and iterating directly, the garbage collector has less work to do and memory usage stays flatter.
🔬 Measurement: The optimization preserves exact behavior (verified via the test suite) while improving the efficiency of the
compute_return_taintandcompute_return_calleeanalysis paths. Measuring peak memory usage during large codebase scans will show the reduction in memory pressure.PR created automatically by Jules for task 3408277797811974874 started by @tachyon-beep