⚡ Bolt: [performance improvement] Avoid eager materialization of AST traversal generators - #161
Conversation
…traversal generators 💡 What: Updated `_assignment_callee` and `_collect_return_paths` in `src/wardline/scanner/taint/variable_level.py` to accept `Iterable[ast.AST]` and passed `ast.iter_child_nodes()` directly instead of eagerly materializing it into lists. Passed `func_node.body` directly instead of `list(func_node.body)`. 🎯 Why: Eagerly materializing generators like `ast.iter_child_nodes()` into lists causes unnecessary memory allocations and overhead, slowing down AST traversal. 📊 Impact: Reduces memory allocations and overhead during L2 taint analysis by lazily evaluating child nodes, making static analysis faster. 🔬 Measurement: Run the test suite and confirm it passes. Benchmark memory usage and execution time of the taint analysis pipeline. 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 reduces unnecessary list allocations during AST traversal in the L2 taint analysis by updating helper functions to accept Iterable[ast.AST] and by passing ast.iter_child_nodes() / func_node.body directly instead of eagerly materializing them.
Changes:
- Update
_assignment_calleeand_collect_return_pathsto acceptIterable[ast.AST]and avoidlist(...)wrappers around AST iterators. - Pass
func_node.bodydirectly (avoid copying the function body list) in return-taint / return-callee computation paths. - Minor formatting-only adjustments in a few tests and MCP/server/install files, plus a new
.jules/bolt.mdnote documenting the learning.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/wardline/scanner/taint/variable_level.py |
Switch traversal helpers to Iterable and remove eager list(...) materialization for child-node traversal and function bodies. |
src/wardline/mcp/server.py |
Formatting-only change to keep trust_packs merge logic on one line. |
src/wardline/install/block.py |
Whitespace-only change (blank lines) around top-level definitions/constants. |
tests/unit/mcp/test_server_trust_grants.py |
Formatting-only change in test fixture file write. |
tests/unit/install/test_mcp_json.py |
Formatting-only changes (single-line json.dumps(...) call and function signature formatting). |
tests/unit/install/test_doctor_pack_grants.py |
Formatting-only change to a test function signature layout. |
.jules/bolt.md |
Adds a short note capturing the performance learning/action for AST generator materialization. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
💡 What: Updated
_assignment_calleeand_collect_return_pathsinsrc/wardline/scanner/taint/variable_level.pyto acceptIterable[ast.AST]and passedast.iter_child_nodes()directly instead of eagerly materializing it into lists. Passedfunc_node.bodydirectly instead oflist(func_node.body).🎯 Why: Eagerly materializing generators like
ast.iter_child_nodes()into lists causes unnecessary memory allocations and overhead, slowing down AST traversal.📊 Impact: Reduces memory allocations and overhead during L2 taint analysis by lazily evaluating child nodes, making static analysis faster.
🔬 Measurement: Run the test suite and confirm it passes. Benchmark memory usage and execution time of the taint analysis pipeline.
PR created automatically by Jules for task 2187943419742031240 started by @tachyon-beep