Skip to content

perf(parser): reserve cap 2 for sequence expressions vec#22374

Merged
graphite-app[bot] merged 1 commit into
mainfrom
c/05-13-perf_parser_reserve_cap_2_for_sequence_expressions
May 13, 2026
Merged

perf(parser): reserve cap 2 for sequence expressions vec#22374
graphite-app[bot] merged 1 commit into
mainfrom
c/05-13-perf_parser_reserve_cap_2_for_sequence_expressions

Conversation

@camc314

@camc314 camc314 commented May 13, 2026

Copy link
Copy Markdown
Contributor

it's impossible to have a sequence expression with a length of 1, so there is no point in creating a vec of len 1, only to re allocate.

This change is visible in the parser via the fewer number of arena re-allocs.

@github-actions github-actions Bot added the A-parser Area - Parser label May 13, 2026

camc314 commented May 13, 2026

Copy link
Copy Markdown
Contributor 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.

@camc314 camc314 changed the title perf(parser): reserve cap 2 for sequence expressions perf(parser): reserve cap 2 for sequence expressions vec May 13, 2026
@codspeed-hq

codspeed-hq Bot commented May 13, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 48 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing c/05-13-perf_parser_reserve_cap_2_for_sequence_expressions (f145820) with main (7c5cfa0)

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.

@camc314 camc314 marked this pull request as ready for review May 13, 2026 07:38
Copilot AI review requested due to automatic review settings May 13, 2026 07:38

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

Note

Copilot was unable to run its full agentic suite in this review.

This PR optimizes parsing of JavaScript sequence expressions by avoiding an initial 1-element arena vector allocation and reserving capacity for the minimum valid sequence length (2), reducing arena reallocations.

Changes:

  • Allocate sequence-expression Vec with capacity 2 instead of creating a 1-element vec.
  • Update the memory allocation snapshot to reflect fewer reallocations during parsing.

Reviewed changes

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

File Description
tasks/track_memory_allocations/allocs_parser.snap Updates allocation/reallocation counts to match the optimization impact.
crates/oxc_parser/src/js/expression.rs Changes sequence-expression collection initialization to reserve capacity 2.

Comment thread tasks/track_memory_allocations/allocs_parser.snap
@camc314 camc314 self-assigned this May 13, 2026
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label May 13, 2026

camc314 commented May 13, 2026

Copy link
Copy Markdown
Contributor Author

Merge activity

it's impossible to have a sequence expression with a length of 1, so there is no point in creating a vec of len 1, only to re allocate.

This change is visible in the parser via the fewer number of arena re-allocs.
@graphite-app graphite-app Bot force-pushed the c/05-13-perf_parser_reserve_cap_2_for_sequence_expressions branch from f145820 to 0b4e158 Compare May 13, 2026 07:46
@graphite-app graphite-app Bot merged commit 0b4e158 into main May 13, 2026
29 checks passed
@graphite-app graphite-app Bot removed the 0-merge Merge with Graphite Merge Queue label May 13, 2026
@graphite-app graphite-app Bot deleted the c/05-13-perf_parser_reserve_cap_2_for_sequence_expressions branch May 13, 2026 07:50
overlookmotel added a commit that referenced this pull request May 15, 2026
### 🚀 Features

- bc91a17 codegen: Expose `Codegen::with_source_type` method (#22432)
(camc314)

### 🐛 Bug Fixes

- 5ac7e79 minifier: Drop unused-var-init pure IIFEs and preserve
annotation for downstream (#22349) (Dunqing)
- 4ab57eb allocator: Fixed-size allocators use `VirtualAlloc` on Windows
(#22124) (overlookmotel)
- 66d77eb allocator: Fix segfault on Linux MUSL with fixed-size
allocators (#22388) (overlookmotel)
- b8fbc1f transformer/object-rest-spread: Correct scope id when moving
bindings (#22419) (camc314)
- 18edc2c codegen: Keep `Object.defineProperty` property name as plain
string in minify (#22400) (Dunqing)
- dda33de transformer/explicit-resource-management: Align lexical
binding scopes (#22320) (camc314)
- 8e79de8 transformer: Preserve for-await statement bodies (#22361)
(camc314)
- 0cba210 transformer/class: Replace `new.target` in static blocks
(#22360) (camc314)
- 67ab1c9 transformer/es2018/for-await: Hoist for-await generated
bindings (#22355) (camc314)
- c3ceb4a transformer/object-rest-spread: Use hoisted scope for `for-of`
temp refs (#22347) (camc314)

### ⚡ Performance

- 73a9043 allocator/bitset: Avoid temp heap `String` allocation (#22403)
(camc314)
- 8b2f4f9 transformer/object-rest-spread: Collect `Vec<SymbolId` over
`Vec<BindingIdentifier>` (#22418) (camc314)
- 83679ea parser: Split TriviaBuilder::handle_token hot/cold paths
(#22415) (Boshen)
- 2c7d781 codegen: Inline identifier-name accessors (#22411) (Boshen)
- 618bc76 diagnostics: Inline `OxcDiagnosticInner` to avoid heap
allocation (#22406) (Boshen)
- 0b4e158 parser: Reserve cap `2` for sequence expressions vec (#22374)
(camc314)
- 5f3bdd0 codegen: Add `#[inline]` to `code`, `code_len` (#22373)
(camc314)

Co-authored-by: overlookmotel <557937+overlookmotel@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-parser Area - Parser

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants