Skip to content

perf(allocator): remove op from StringBuilder::grow_one#20650

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/02-20-perf_allocator_remove_op_from_stringbuilder_grow_one_
Mar 23, 2026
Merged

perf(allocator): remove op from StringBuilder::grow_one#20650
graphite-app[bot] merged 1 commit intomainfrom
om/02-20-perf_allocator_remove_op_from_stringbuilder_grow_one_

Conversation

@overlookmotel
Copy link
Copy Markdown
Member

@overlookmotel overlookmotel commented Mar 23, 2026

Remove a bounds check from StringBuilder::grow_one (which is used by StringBuilder::push_ascii_byte). Rationale is explained in comment added in this PR.

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

@github-actions github-actions bot added the C-performance Category - Solution not expected to change functional behavior, only performance label Mar 23, 2026
@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 om/02-20-perf_allocator_remove_op_from_stringbuilder_grow_one_ (b8470d3) with main (399e629)

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.

@overlookmotel overlookmotel marked this pull request as ready for review March 23, 2026 09:52
Copilot AI review requested due to automatic review settings March 23, 2026 09:52
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 oxc_allocator’s StringBuilder growth path by removing a redundant overflow check in StringBuilder::grow_one, which is on the hot path for single-byte pushes (e.g. push_ascii_byte).

Changes:

  • Replaced checked_add(...).expect(...) with a direct current_capacity + additional in StringBuilder::grow_one.
  • Added an explanatory comment documenting why usize overflow cannot occur for this addition under the existing capacity invariants.

@overlookmotel overlookmotel self-assigned this Mar 23, 2026
@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Mar 23, 2026
Copy link
Copy Markdown
Member Author

overlookmotel commented Mar 23, 2026

Merge activity

Remove a bounds check from `StringBuilder::grow_one` (which is used by `StringBuilder::push_ascii_byte`). Rationale is explained in comment added in this PR.
@graphite-app graphite-app bot force-pushed the om/02-20-perf_allocator_remove_op_from_stringbuilder_grow_one_ branch from b8470d3 to 89a5374 Compare March 23, 2026 10:00
@graphite-app graphite-app bot merged commit 89a5374 into main Mar 23, 2026
27 checks passed
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 23, 2026
@graphite-app graphite-app bot deleted the om/02-20-perf_allocator_remove_op_from_stringbuilder_grow_one_ branch March 23, 2026 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

2 participants