Skip to content

perf(parser): reduce Kind to ModifierKind conversions in eat_modifiers_before_declaration#20820

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

perf(parser): reduce Kind to ModifierKind conversions in eat_modifiers_before_declaration#20820
graphite-app[bot] merged 1 commit intomainfrom
om/03-28-perf_parser_reduce_kind_to_modifierkind_conversions_in_eat_modifiers_before_declaration_

Conversation

@overlookmotel
Copy link
Copy Markdown
Member

@overlookmotel overlookmotel commented Mar 28, 2026

Small perf optimization.

eat_modifiers_before_declaration was converting Kind to ModifierKind twice - once in self.at_modifier() (kind.is_modifier_kind()), and then again in self.modifier() (ModifierKind::try_from(kind)).

Instead, convert only once.

+0.1% improvement on most parser benchmarks.

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.

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

Optimizes oxc_parser modifier parsing by avoiding redundant Kind -> ModifierKind conversions in eat_modifiers_before_declaration, keeping the same lookahead-based correctness checks while reducing work on the hot path.

Changes:

  • Replace at_modifier() + modifier() flow with a single get_modifier() that returns Option<ModifierKind>.
  • Construct Modifier directly from the already-converted ModifierKind.
  • Rename/update the lookahead worker accordingly.

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

@camc314 camc314 self-assigned this Mar 29, 2026
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Mar 29, 2026
@camc314 camc314 removed their assignment Mar 29, 2026
Copy link
Copy Markdown
Contributor

camc314 commented Mar 29, 2026

Merge activity

  • Mar 29, 3:30 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:31 PM UTC: camc314 added this pull request to the Graphite merge queue.
  • Mar 29, 3:35 PM UTC: The Graphite merge queue removed this pull request due to downstack failures on PR #20781.
  • Mar 29, 3:35 PM UTC: The Graphite merge queue removed this pull request due to downstack failures on PR #20781.
  • Mar 29, 3:36 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:36 PM UTC: The merge label '0-merge' was removed. This PR will no longer be merged by the Graphite merge queue
  • Mar 29, 3:37 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:37 PM UTC: The merge label '0-merge' was removed. This PR will no longer be merged by the Graphite merge queue
  • Mar 29, 3:38 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: camc314 added this pull request to the Graphite merge queue.
  • Mar 29, 3:40 PM UTC: graphite-app removed this pull request from the Graphite merge queue.
  • Mar 29, 3:40 PM UTC: The merge label '0-merge' was removed. This PR will no longer be merged by the Graphite merge queue
  • Mar 29, 3:41 PM UTC: camc314 added this pull request to the Graphite merge queue.
  • Mar 29, 4:20 PM UTC: This pull request was removed from the Graphite merge queue because the batch it was included in timed out. Please re-enqueue the PR to retry merge.
  • Mar 29, 4:37 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:37 PM UTC: camc314 added this pull request to the Graphite merge queue.
  • Mar 29, 4:37 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 changed the base branch from om/03-26-refactor_parser_shorten_code_handling_illegal_modifiers to graphite-base/20820 March 29, 2026 15:36
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Mar 29, 2026 — with Graphite App
graphite-app bot pushed a commit that referenced this pull request Mar 29, 2026
…ifiers_before_declaration` (#20820)

Small perf optimization.

`eat_modifiers_before_declaration` was converting `Kind` to `ModifierKind` twice - once in `self.at_modifier()` (`kind.is_modifier_kind()`), and then again in `self.modifier()` (`ModifierKind::try_from(kind)`).

Instead, convert only once.

+0.1% improvement on most parser benchmarks.
@graphite-app graphite-app bot force-pushed the om/03-28-perf_parser_reduce_kind_to_modifierkind_conversions_in_eat_modifiers_before_declaration_ branch from ebbdd03 to ccbd3e9 Compare March 29, 2026 15:42
@graphite-app graphite-app bot changed the base branch from graphite-base/20820 to om/03-26-refactor_parser_shorten_code_handling_illegal_modifiers March 29, 2026 15:42
Base automatically changed from om/03-26-refactor_parser_shorten_code_handling_illegal_modifiers to main March 29, 2026 15:47
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 29, 2026
…ifiers_before_declaration` (#20820)

Small perf optimization.

`eat_modifiers_before_declaration` was converting `Kind` to `ModifierKind` twice - once in `self.at_modifier()` (`kind.is_modifier_kind()`), and then again in `self.modifier()` (`ModifierKind::try_from(kind)`).

Instead, convert only once.

+0.1% improvement on most parser benchmarks.
@camc314 camc314 force-pushed the om/03-28-perf_parser_reduce_kind_to_modifierkind_conversions_in_eat_modifiers_before_declaration_ branch from ccbd3e9 to eb02c88 Compare March 29, 2026 16:34
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Mar 29, 2026
@graphite-app graphite-app bot merged commit eb02c88 into main Mar 29, 2026
35 checks passed
@graphite-app graphite-app bot deleted the om/03-28-perf_parser_reduce_kind_to_modifierkind_conversions_in_eat_modifiers_before_declaration_ branch March 29, 2026 16:37
@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