Skip to content

perf(parser): defer calculation of Modifier spans#20823

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/03-28-perf_parser_defer_calculation_of_modifier_spans
Mar 29, 2026
Merged

perf(parser): defer calculation of Modifier spans#20823
graphite-app[bot] merged 1 commit intomainfrom
om/03-28-perf_parser_defer_calculation_of_modifier_spans

Conversation

@overlookmotel
Copy link
Copy Markdown
Member

@overlookmotel overlookmotel commented Mar 28, 2026

Small perf optimization.

The Span of a modifier is only required when an error is raised (cold path).

Don't eagerly calculate and store the full span in Modifier, only store the span's start. Calculate the span's end lazily only when it's needed (which it only is if source contains syntax errors).

Copy link
Copy Markdown
Member Author

overlookmotel commented Mar 28, 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.

@overlookmotel overlookmotel marked this pull request as ready for review March 28, 2026 16:19
Copilot AI review requested due to automatic review settings March 28, 2026 16:19
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 28, 2026

Merging this PR will not alter performance

✅ 48 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing om/03-28-perf_parser_defer_calculation_of_modifier_spans (055a7ac) with main (eb02c88)2

Open in CodSpeed

Footnotes

  1. 8 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 main (055a7ac) during the generation of this report, so eb02c88 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

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 optimizes modifier handling in oxc_parser by deferring full Span reconstruction for modifiers until it’s actually needed (primarily diagnostics), reducing work on the hot parsing path.

Changes:

  • Replace stored Modifier.span: Span with Modifier.span_start: u32 and reconstruct spans lazily via Modifier::span().
  • Update modifier parsing/collection to record only start offsets.
  • Update diagnostics and call sites to use modifier.span() instead of the removed modifier.span field.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
crates/oxc_parser/src/modifiers.rs Changes Modifier to store only span_start, adds lazy span() reconstruction, and updates modifier parsing/collection paths accordingly.
crates/oxc_parser/src/js/module.rs Adjusts duplicate export-modifier diagnostic construction to match the new Modifier::new(span_start, kind) API.
crates/oxc_parser/src/js/class.rs Updates diagnostics call sites to use modifier.span() accessor.
crates/oxc_parser/src/diagnostics.rs Updates modifier-related diagnostics to label using modifier.span() instead of a stored span field.

@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Mar 29, 2026
Copy link
Copy Markdown
Contributor

camc314 commented Mar 29, 2026

Merge activity

  • Mar 29, 3:31 PM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Mar 29, 3:40 PM UTC: The Graphite merge queue removed this pull request due to removal of a downstack PR #20820.
  • Mar 29, 3:40 PM UTC: camc314 added this pull request to the Graphite merge queue.
  • Mar 29, 3:41 PM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Mar 29, 3:41 PM UTC: The merge label '0-merge' was removed. This PR will no longer be merged by the Graphite merge queue
  • Mar 29, 3:42 PM UTC: camc314 added this pull request to the Graphite merge queue.
  • Mar 29, 4:19 PM UTC: The Graphite merge queue removed this pull request due to downstack failures on PR #20820.
  • Mar 29, 4:43 PM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Mar 29, 4:43 PM UTC: camc314 added this pull request to the Graphite merge queue.
  • Mar 29, 4:43 PM UTC: Merged by the Graphite merge queue.

@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 29, 2026
@graphite-app graphite-app bot force-pushed the om/03-28-perf_parser_remove_branch_from_parse_modifiers_ branch from 26f05f9 to b3ca6a4 Compare March 29, 2026 15:43
graphite-app bot pushed a commit that referenced this pull request Mar 29, 2026
Small perf optimization.

The `Span` of a modifier is only required when an error is raised (cold path).

Don't eagerly calculate and store the full span in `Modifier`, only store the span's start. Calculate the span's end lazily only when it's needed (which it only is if source contains syntax errors).
@graphite-app graphite-app bot force-pushed the om/03-28-perf_parser_defer_calculation_of_modifier_spans branch from e6c5fb8 to 45d7efb Compare March 29, 2026 15:43
@graphite-app graphite-app bot force-pushed the om/03-28-perf_parser_remove_branch_from_parse_modifiers_ branch from b3ca6a4 to 2e7e6bd Compare March 29, 2026 16:38
Small perf optimization.

The `Span` of a modifier is only required when an error is raised (cold path).

Don't eagerly calculate and store the full span in `Modifier`, only store the span's start. Calculate the span's end lazily only when it's needed (which it only is if source contains syntax errors).
@graphite-app graphite-app bot force-pushed the om/03-28-perf_parser_defer_calculation_of_modifier_spans branch from 45d7efb to 055a7ac Compare March 29, 2026 16:38
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Mar 29, 2026
Base automatically changed from om/03-28-perf_parser_remove_branch_from_parse_modifiers_ to main March 29, 2026 16:42
@graphite-app graphite-app bot merged commit 055a7ac into main Mar 29, 2026
36 checks passed
@graphite-app graphite-app bot deleted the om/03-28-perf_parser_defer_calculation_of_modifier_spans branch March 29, 2026 16:43
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-parser Area - Parser 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.

3 participants