Skip to content

perf(parser): pre-allocate extends vec with 1 cap#20667

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/03-23-perf_parser_pre-allocate_extends_vec_with_1_cap
Mar 24, 2026
Merged

perf(parser): pre-allocate extends vec with 1 cap#20667
graphite-app[bot] merged 1 commit intomainfrom
c/03-23-perf_parser_pre-allocate_extends_vec_with_1_cap

Conversation

@camc314
Copy link
Copy Markdown
Contributor

@camc314 camc314 commented Mar 23, 2026

if we hit here, it means that we've seen the extends keyword - having code like class foo extends {} is invalid as there must be at least one extends expression, so min size of the extendsvec will be 1.

This just avoids the re-alloc

@github-actions github-actions bot added A-parser Area - Parser C-performance Category - Solution not expected to change functional behavior, only performance labels Mar 23, 2026
Copy link
Copy Markdown
Contributor Author

camc314 commented Mar 23, 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.

@camc314 camc314 marked this pull request as ready for review March 23, 2026 21:40
Copilot AI review requested due to automatic review settings March 23, 2026 21:40
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 makes a small parser performance tweak by pre-allocating the extends list with capacity 1 in class heritage parsing, avoiding an initial grow on the common single-extends case.

Changes:

  • Pre-allocate the extends vector in parse_extends_clause using vec_with_capacity(1) instead of vec().

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 23, 2026

Merging this PR will not alter performance

✅ 53 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing c/03-23-perf_parser_pre-allocate_extends_vec_with_1_cap (4172d22) with c/03-23-perf_parser_avoid_re-allocating_when_parsing_import_stmt (2cb0cb3)

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.

@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Mar 24, 2026
Copy link
Copy Markdown
Member

Boshen commented Mar 24, 2026

Merge activity

if we hit here, it means that we've seen the `extends` keyword - having code like `class foo extends {}` is invalid as there must be at least one extends expression, so min size of the `extends`vec will be 1.

This just avoids the re-alloc
@graphite-app graphite-app bot force-pushed the c/03-23-perf_parser_avoid_re-allocating_when_parsing_import_stmt branch from 2cb0cb3 to ad58dd7 Compare March 24, 2026 04:01
@graphite-app graphite-app bot force-pushed the c/03-23-perf_parser_pre-allocate_extends_vec_with_1_cap branch from 4172d22 to 611fca5 Compare March 24, 2026 04:02
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 24, 2026
Base automatically changed from c/03-23-perf_parser_avoid_re-allocating_when_parsing_import_stmt to main March 24, 2026 04:04
@graphite-app graphite-app bot merged commit 611fca5 into main Mar 24, 2026
28 checks passed
@graphite-app graphite-app bot deleted the c/03-23-perf_parser_pre-allocate_extends_vec_with_1_cap branch March 24, 2026 04:05
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