Skip to content

perf(parser): add #[inline(always)] to finish_next_inner#19694

Closed
overlookmotel wants to merge 1 commit intomainfrom
om/02-24-perf_parser_add_inline_always_to_finish_next_inner_
Closed

perf(parser): add #[inline(always)] to finish_next_inner#19694
overlookmotel wants to merge 1 commit intomainfrom
om/02-24-perf_parser_add_inline_always_to_finish_next_inner_

Conversation

@overlookmotel
Copy link
Member

No description provided.

Copy link
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 hot fixes, skip the queue and merge this PR next

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-parser Area - Parser C-performance Category - Solution not expected to change functional behavior, only performance labels Feb 24, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 24, 2026

Merging this PR will improve performance by 8.57%

⚡ 4 improved benchmarks
✅ 48 untouched benchmarks
⏩ 3 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation parser_tokens[react.development.js] 1.5 ms 1.4 ms +4.82%
Simulation parser_tokens[RadixUIAdoptionSection.jsx] 94.4 µs 87 µs +8.57%
Simulation parser_tokens[cal.com.tsx] 30.3 ms 28.9 ms +4.72%
Simulation parser_tokens[binder.ts] 3.8 ms 3.6 ms +4.58%

Comparing om/02-24-perf_parser_add_inline_always_to_finish_next_inner_ (b010c4b) with main (ce7e253)

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.

graphite-app bot pushed a commit that referenced this pull request Feb 25, 2026
…9684)

Replace const generic param from `finish_next_inner`.

```diff
- fn finish_next_inner<const REPLACE_SAME_START: bool>(&mut self, kind: Kind) -> Token {
+ fn finish_next_inner(&mut self, kind: Kind, mode: FinishTokenMode) -> Token {
```

The function is marked `#[inline(always)]` to ensure that `mode` can be statically known from each call site and acts as a const.

The perf improvement (5%-8% on `parser_tokens` benchmarks) surprised me. Turns out it's the result of the `#[inline(always)]` (see #19694 which made that change in isolation).

Aside from the perf improvement, it's easier to read, and may reduce compile time a bit (as this function is inlined into many call sites).
@overlookmotel overlookmotel deleted the om/02-24-perf_parser_add_inline_always_to_finish_next_inner_ branch February 27, 2026 00:42
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.

1 participant