Skip to content

perf(ast_tools): introduce StructsMut iterator and use it where possible#20949

Merged
graphite-app[bot] merged 1 commit into
mainfrom
om/04-01-perf_ast_tools_introduce_structsmut_iterator_and_use_it_where_possible
Apr 1, 2026
Merged

perf(ast_tools): introduce StructsMut iterator and use it where possible#20949
graphite-app[bot] merged 1 commit into
mainfrom
om/04-01-perf_ast_tools_introduce_structsmut_iterator_and_use_it_where_possible

Conversation

@overlookmotel

@overlookmotel overlookmotel commented Apr 1, 2026

Copy link
Copy Markdown
Member

Same as #20943. Introduce a StructsMut iterator, which is more efficient than iterating through all types.

Copy link
Copy Markdown
Member Author

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions Bot added A-ast-tools Area - AST tools C-performance Category - Solution not expected to change functional behavior, only performance labels Apr 1, 2026
@overlookmotel
overlookmotel marked this pull request as ready for review April 1, 2026 20:20
Copilot AI review requested due to automatic review settings April 1, 2026 20:20
@overlookmotel overlookmotel self-assigned this Apr 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 improves ast_tools generator performance by adding a mutable iterator that walks only AST structs (and stops once non-AST types begin), avoiding repeated full-schema scans.

Changes:

  • Added Schema::structs_mut() and a new StructsMut iterator to yield &mut StructDef efficiently.
  • Updated AstKindGenerator::prepare to use structs_mut() instead of iterating all schema.types.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tasks/ast_tools/src/schema/mod.rs Introduces StructsMut and Schema::structs_mut() for efficient mutable iteration over AST structs with early termination.
tasks/ast_tools/src/generators/ast_kind.rs Uses schema.structs_mut() to set has_kind only on structs, avoiding scanning all type defs.

@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Apr 1, 2026

overlookmotel commented Apr 1, 2026

Copy link
Copy Markdown
Member Author

Merge activity

…sible (#20949)

Same as #20943. Introduce a `StructsMut` iterator, which is more efficient than iterating through all types.
@graphite-app
graphite-app Bot force-pushed the om/04-01-perf_ast_tools_introduce_structsmut_iterator_and_use_it_where_possible branch from d8a5101 to 2ac7527 Compare April 1, 2026 20:28
@graphite-app
graphite-app Bot merged commit 2ac7527 into main Apr 1, 2026
24 checks passed
@graphite-app graphite-app Bot removed the 0-merge Merge with Graphite Merge Queue label Apr 1, 2026
@graphite-app
graphite-app Bot deleted the om/04-01-perf_ast_tools_introduce_structsmut_iterator_and_use_it_where_possible branch April 1, 2026 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast-tools Area - AST tools C-performance Category - Solution not expected to change functional behavior, only performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants