⚡ Bolt: Avoid eager materialization of AST child nodes - #136
Conversation
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
This PR improves AST traversal performance in the taint-tracking scanner by avoiding eager list(...) materialization of ast.iter_child_nodes(...) during recursive descent.
Changes:
- Updated recursive traversal helpers to accept
Iterable[ast.AST]instead oflist[ast.AST]. - Replaced
list(ast.iter_child_nodes(node))withast.iter_child_nodes(node)in recursive calls to reduce allocations. - Added a short “Bolt” note documenting the optimization guideline.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/wardline/scanner/taint/variable_level.py | Switches recursive AST traversal to consume iterables/generators directly to avoid eager list allocations. |
| .jules/bolt.md | Documents the performance learning/action for future AST traversal changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| nested = _assignment_callee( | ||
| list(ast.iter_child_nodes(node)), name, worst, function_taint, taint_map, var_taints | ||
| ) | ||
| nested = _assignment_callee(ast.iter_child_nodes(node), name, worst, function_taint, taint_map, var_taints) |
💡 What: Passing
ast.iter_child_nodesgenerator directly into recursive functions instead of wrapping them inlist()insrc/wardline/scanner/taint/variable_level.py.🎯 Why: Eagerly materializing AST node generators creates unnecessary memory allocations and performance overhead during deep or recursive AST traversals in taint tracking.
📊 Impact: Reduces memory allocations during recursive static analysis over AST nodes.
🔬 Measurement: Verify tests run successfully; observe memory profiling during deep AST scans if needed.
PR created automatically by Jules for task 7038201939160521137 started by @tachyon-beep