Skip to content

⚡ Bolt: [performance improvement] Avoid eager list materialization in AST traversals - #158

Open
tachyon-beep wants to merge 2 commits into
mainfrom
bolt-ast-traversal-optimization-10599748386960697458
Open

⚡ Bolt: [performance improvement] Avoid eager list materialization in AST traversals#158
tachyon-beep wants to merge 2 commits into
mainfrom
bolt-ast-traversal-optimization-10599748386960697458

Conversation

@tachyon-beep

Copy link
Copy Markdown
Collaborator

💡 What: Modified _collect_return_paths and _assignment_callee to accept Iterable[ast.AST] instead of list[ast.AST], and removed the list() wrapper around generator expressions like ast.iter_child_nodes(node) and property accesses like func_node.body.

🎯 Why: Eager list materialization forces Python to allocate a list in memory and iterate through the generator to fill it before passing it to the function. Since the function just iterates over the nodes anyway, this is a waste of memory and CPU cycles.

📊 Impact: Eliminates unnecessary list allocations during per-variable taint tracking, saving memory and avoiding an O(N) memory allocation step at every level of the AST during L2 processing.

🔬 Measurement: Observe memory usage during scans on large Python projects. Verify that tests continue to pass and no regressions have been introduced.


PR created automatically by Jules for task 10599748386960697458 started by @tachyon-beep

… AST traversals

💡 What:
Modified `_collect_return_paths` and `_assignment_callee` to accept `Iterable[ast.AST]` instead of `list[ast.AST]`, and removed the `list()` wrapper around generator expressions like `ast.iter_child_nodes(node)` and property accesses like `func_node.body`.

🎯 Why:
Eager list materialization forces Python to allocate a list in memory and iterate through the generator to fill it before passing it to the function. Since the function just iterates over the nodes anyway, this is a waste of memory and CPU cycles.

📊 Impact:
Eliminates unnecessary list allocations during per-variable taint tracking, saving memory and avoiding an O(N) memory allocation step at every level of the AST during L2 processing.

🔬 Measurement:
Observe memory usage during scans on large Python projects. Verify that tests continue to pass and no regressions have been introduced.

Co-authored-by: tachyon-beep <544926+tachyon-beep@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 21, 2026 16:23
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes AST traversal in the taint scanner by removing unnecessary eager list materialization and widening helper function inputs from list[ast.AST] to Iterable[ast.AST], reducing allocations during recursive walks.

Changes:

  • Updated _collect_return_paths and _assignment_callee to accept Iterable[ast.AST].
  • Removed list(...) wrappers around func_node.body and ast.iter_child_nodes(node) at call sites to avoid eager allocation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

… AST traversals

💡 What:
Modified `_collect_return_paths` and `_assignment_callee` to accept `Iterable[ast.AST]` instead of `list[ast.AST]`, and removed the `list()` wrapper around generator expressions like `ast.iter_child_nodes(node)` and property accesses like `func_node.body`. This also includes auto-formatting fixes that failed in CI.

🎯 Why:
Eager list materialization forces Python to allocate a list in memory and iterate through the generator to fill it before passing it to the function. Since the function just iterates over the nodes anyway, this is a waste of memory and CPU cycles.

📊 Impact:
Eliminates unnecessary list allocations during per-variable taint tracking, saving memory and avoiding an O(N) memory allocation step at every level of the AST during L2 processing.

🔬 Measurement:
Observe memory usage during scans on large Python projects. Verify that tests continue to pass and no regressions have been introduced.

Co-authored-by: tachyon-beep <544926+tachyon-beep@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants