Skip to content

perf: reduce string allocations#10423

Merged
graphite-app[bot] merged 1 commit into
mainfrom
om/07-23-perf_hmr_module_finalizer_reduce_string_allocations
Jul 24, 2026
Merged

perf: reduce string allocations#10423
graphite-app[bot] merged 1 commit into
mainfrom
om/07-23-perf_hmr_module_finalizer_reduce_string_allocations

Conversation

@overlookmotel

@overlookmotel overlookmotel commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Follow-on after #10018, continuation of #10420 and #10421.

Where we already have a Str<'ast> or Ident<'ast>, avoid converting it into a &str and then allocating it back into arena again to convert back to Str or Ident. Just re-use the existing Str / Ident. This avoids unnecessary arena allocations, and in the case of Ident, it avoids re-hashing the string too.

overlookmotel commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator Author

How to use the Graphite Merge Queue

Add the label graphite: merge-when-ready to this PR to add it to 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.

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

This PR continues the post-oxc-constructor migration performance work by reusing already-arena-backed Str<'ast> / Ident<'ast> values when building new AST nodes, avoiding redundant &str conversions and re-allocation (and for identifiers, avoiding re-hashing in some paths).

Changes:

  • Reuse existing Str/Ident values when constructing IdentifierName, StringLiteral, and identifier expressions in the HMR AST finalizer.
  • Simplify property-key construction in the module finalizer by using PropertyKey::new_static_identifier(...) directly (removing IntoIn/manual boxing/allocation patterns).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
crates/rolldown/src/module_finalizers/impl_visit_mut.rs Switches assignment-target property key construction to reuse existing arena strings via PropertyKey::new_static_identifier.
crates/rolldown/src/hmr/hmr_ast_finalizer.rs Reuses existing Str/Ident values for member-expression properties, string literals, and exported identifier expressions to reduce arena allocations.

@codspeed-hq

codspeed-hq Bot commented Jul 23, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 7 untouched benchmarks
⏩ 10 skipped benchmarks1


Comparing om/07-23-perf_hmr_module_finalizer_reduce_string_allocations (6466383) with om/07-23-perf_hmr_remove_unnecessary_string_allocations (9d0b7c0)2

Open in CodSpeed

Footnotes

  1. 10 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 om/07-23-perf_hmr_remove_unnecessary_string_allocations (f677ba7) during the generation of this report, so 980edf9 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@overlookmotel overlookmotel changed the title perf(hmr, module_finalizer): reduce string allocations perf: reduce string allocations Jul 24, 2026
@overlookmotel
overlookmotel force-pushed the om/07-23-perf_hmr_remove_unnecessary_string_allocations branch from 9d0b7c0 to f677ba7 Compare July 24, 2026 00:02
@overlookmotel
overlookmotel force-pushed the om/07-23-perf_hmr_module_finalizer_reduce_string_allocations branch from c583ea9 to 6466383 Compare July 24, 2026 00:02

@hyfdev hyfdev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

— Review by @hyfdev, assisted by GPT-5

@graphite-app

graphite-app Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Merge activity

Follow-on after #10018, continuation of #10420 and #10421.

Where we already have a `Str<'ast>` or `Ident<'ast>`, avoid converting it into a `&str` and then allocating it back into arena again to convert back to `Str` or `Ident`. Just re-use the existing `Str` / `Ident`. This avoids unnecessary arena allocations, and in the case of `Ident`, it avoids re-hashing the string too.
@graphite-app
graphite-app Bot force-pushed the om/07-23-perf_hmr_remove_unnecessary_string_allocations branch from f677ba7 to 89ec37d Compare July 24, 2026 03:45
@graphite-app
graphite-app Bot force-pushed the om/07-23-perf_hmr_module_finalizer_reduce_string_allocations branch from 6466383 to 55729bb Compare July 24, 2026 03:46
Base automatically changed from om/07-23-perf_hmr_remove_unnecessary_string_allocations to main July 24, 2026 03:57
@graphite-app
graphite-app Bot merged commit 55729bb into main Jul 24, 2026
31 of 32 checks passed
@graphite-app
graphite-app Bot deleted the om/07-23-perf_hmr_module_finalizer_reduce_string_allocations branch July 24, 2026 03:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants