perf(codegen): inline identifier-name accessors#22411
Merged
Merged
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
Member
Author
Merge activity
|
## Summary `Codegen::get_identifier_reference_name` and `Codegen::get_binding_identifier_name` are called once per identifier emission (every `IdentifierReference`, `BindingIdentifier`, import/export spec, etc.) but were not marked `#[inline]`. The bodies are short and in the common case (no scoping i.e. no mangling) compile to a couple of loads, so the function-call overhead is a noticeable share of codegen self-time on identifier-heavy inputs. ## Measurements Wall-time on codegen-only loop (parse once, codegen N times), `--profile release-with-debug`, median of 3 runs: | file | before | after | delta | |---|---|---|---| | antd.js (6.7M) | 14.49 ms/iter | 13.25 ms/iter | **-8.6%** | | checker.ts (2.8M) | 4.35 ms/iter | 4.12 ms/iter | **-5.3%** | | binder.ts (189K) | 155 µs/iter | 150 µs/iter | -3.2% | | pdf.mjs (554K) | 961 µs/iter | 935 µs/iter | -2.7% | | cal.com.tsx (1.0M) | 1.46 ms/iter | 1.48 ms/iter | noise | xctrace Time Profiler self-time on `Codegen::get_identifier_reference_name` (antd.js): 0.50% → 0.33%; samples redistribute into `GenExpr::print_expr` (the inlining call site) as expected. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
4285b03 to
2c7d781
Compare
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Codegen::get_identifier_reference_nameandCodegen::get_binding_identifier_nameare called once per identifier emission (everyIdentifierReference,BindingIdentifier, import/export spec, etc.) but were not marked#[inline]. The bodies are short and in the common case (no scoping i.e. no mangling) compile to a couple of loads, so the function-call overhead is a noticeable share of codegen self-time on identifier-heavy inputs.Measurements
Wall-time on codegen-only loop (parse once, codegen N times),
--profile release-with-debug, median of 3 runs:xctrace Time Profiler self-time on
Codegen::get_identifier_reference_name(antd.js): 0.50% → 0.33%; samples redistribute intoGenExpr::print_expr(the inlining call site) as expected.🤖 Generated with Claude Code