Skip to content

perf(ast): mark AstKind::span as #[inline]#20585

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/02-15-perf_ast_mark_astkind_span_as_inline_
Mar 20, 2026
Merged

perf(ast): mark AstKind::span as #[inline]#20585
graphite-app[bot] merged 1 commit intomainfrom
om/02-15-perf_ast_mark_astkind_span_as_inline_

Conversation

@overlookmotel
Copy link
Copy Markdown
Member

@overlookmotel overlookmotel commented Mar 20, 2026

Now that AstKind's variants are all structs (no enums any more), and #20584 has ensured that Span is in a consistent position in all structs, AstKind::span should boil down to a single operation - a pointer read. Therefore, mark it #[inline].

Note: Span was already in a consistent position prior to #20584, but that was more by accident than anything else. Now it's guaranteed. But this change won't make a difference to perf, it just guards against a perf regression in future.

Copy link
Copy Markdown
Member Author

overlookmotel commented Mar 20, 2026


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 Area - AST A-ast-tools Area - AST tools C-performance Category - Solution not expected to change functional behavior, only performance labels Mar 20, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 20, 2026

Merging this PR will not alter performance

✅ 53 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing om/02-15-perf_ast_mark_astkind_span_as_inline_ (c9edd39) with om/02-15-perf_ast_place_nodeid_field_after_span_in_structs (b258884)2

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on om/02-15-perf_ast_place_nodeid_field_after_span_in_structs (2064ade) during the generation of this report, so 9b52103 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@overlookmotel overlookmotel marked this pull request as ready for review March 20, 2026 21:38
Copilot AI review requested due to automatic review settings March 20, 2026 21:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 adds an #[inline] hint to AstKind’s GetSpan::span implementation to help prevent future performance regressions now that AST node span fields are guaranteed to be laid out consistently.

Changes:

  • Add documentation explaining why AstKind::span should be cheap (consistent span field placement).
  • Add #[inline] to the GetSpan for AstKind<'_> span() implementation in the generator and regenerated output.

Reviewed changes

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

File Description
tasks/ast_tools/src/generators/ast_kind.rs Updates the code generator to emit docs + #[inline] on AstKind’s GetSpan::span.
crates/oxc_ast/src/generated/ast_kind.rs Regenerates AstKind to include the new docs + #[inline] on span().

@overlookmotel overlookmotel self-assigned this Mar 20, 2026
@overlookmotel overlookmotel force-pushed the om/02-15-perf_ast_mark_astkind_span_as_inline_ branch from 9eaf443 to c9edd39 Compare March 20, 2026 22:02
@overlookmotel overlookmotel force-pushed the om/02-15-perf_ast_place_nodeid_field_after_span_in_structs branch from b258884 to 2064ade Compare March 20, 2026 22:02
@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Mar 20, 2026
@graphite-app
Copy link
Copy Markdown
Contributor

graphite-app bot commented Mar 20, 2026

Merge activity

Now that `AstKind`'s variants are all structs (no enums any more), and #20584 has ensured that `Span` is in a consistent position in all structs, `AstKind::span` should boil down to a single operation - a pointer read. Therefore, mark it `#[inline]`.

Note: `Span` was already in a consistent position prior to #20584, but that was more by accident than anything else. Now it's guaranteed. But this change won't make a difference to perf, it just guards against a perf regression in future.
@graphite-app graphite-app bot force-pushed the om/02-15-perf_ast_place_nodeid_field_after_span_in_structs branch from 2064ade to c6ea0a0 Compare March 20, 2026 22:20
@graphite-app graphite-app bot requested review from camc314 and leaysgur as code owners March 20, 2026 22:20
@graphite-app graphite-app bot force-pushed the om/02-15-perf_ast_mark_astkind_span_as_inline_ branch from c9edd39 to 3420abb Compare March 20, 2026 22:20
graphite-app bot pushed a commit that referenced this pull request Mar 20, 2026
Similar to #20585. As `AstKind`'s variants are all structs (no enums any more), and all structs have an `AstKind`, `AstKind::address` method boils down to a no-op. So mark it `#[inline]`.

Also remove some defunct code from `AstKind` codegen which was handling when an `AstKind` refers to an enum. This circumstance is no longer possible, so remove this code.
@graphite-app graphite-app bot removed 0-merge Merge with Graphite Merge Queue labels Mar 20, 2026
Base automatically changed from om/02-15-perf_ast_place_nodeid_field_after_span_in_structs to main March 20, 2026 22:29
@graphite-app graphite-app bot merged commit 3420abb into main Mar 20, 2026
26 checks passed
@graphite-app graphite-app bot deleted the om/02-15-perf_ast_mark_astkind_span_as_inline_ branch March 20, 2026 22:30
costajohnt pushed a commit to costajohnt/oxc that referenced this pull request Mar 22, 2026
Now that `AstKind`'s variants are all structs (no enums any more), and oxc-project#20584 has ensured that `Span` is in a consistent position in all structs, `AstKind::span` should boil down to a single operation - a pointer read. Therefore, mark it `#[inline]`.

Note: `Span` was already in a consistent position prior to oxc-project#20584, but that was more by accident than anything else. Now it's guaranteed. But this change won't make a difference to perf, it just guards against a perf regression in future.
costajohnt pushed a commit to costajohnt/oxc that referenced this pull request Mar 22, 2026
Similar to oxc-project#20585. As `AstKind`'s variants are all structs (no enums any more), and all structs have an `AstKind`, `AstKind::address` method boils down to a no-op. So mark it `#[inline]`.

Also remove some defunct code from `AstKind` codegen which was handling when an `AstKind` refers to an enum. This circumstance is no longer possible, so remove this code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast Area - AST 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