perf(allocator): add #[cold] annotations to error handling functions#18181
Merged
graphite-app[bot] merged 1 commit intomainfrom Jan 18, 2026
Merged
perf(allocator): add #[cold] annotations to error handling functions#18181graphite-app[bot] merged 1 commit intomainfrom
graphite-app[bot] merged 1 commit intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds performance optimization attributes (#[cold] and #[inline(never)]) to error handling and panic functions in the oxc_allocator crate to improve branch prediction and code layout for hot allocation paths.
Changes:
- Added
#[cold]attribute toallocation_size_overflowinbump.rs(already had#[inline(never)]) - Added both
#[cold]and#[inline(never)]attributes tonew_layout_errandhandle_alloc_errorinbumpalo_alloc.rs - Added both
#[cold]and#[inline(never)]attributes tocapacity_overflowinvec2/raw_vec.rs
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
crates/oxc_allocator/src/bump.rs |
Added #[cold] to allocation_size_overflow function |
crates/oxc_allocator/src/bumpalo_alloc.rs |
Added #[cold] and #[inline(never)] to new_layout_err and handle_alloc_error functions |
crates/oxc_allocator/src/vec2/raw_vec.rs |
Added #[cold] and #[inline(never)] to capacity_overflow function |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merging this PR will not alter performance
Comparing Footnotes
|
Member
Author
Merge activity
|
…18181) ## Summary - Add `#[cold]` and `#[inline(never)]` annotations to error/panic functions in oxc_allocator - Improves branch prediction and code layout for hot allocation paths ### Functions annotated | File | Function | Change | |------|----------|--------| | `bump.rs` | `allocation_size_overflow` | Added `#[cold]` | | `bumpalo_alloc.rs` | `new_layout_err` | Added `#[cold]` + `#[inline(never)]` | | `bumpalo_alloc.rs` | `handle_alloc_error` | Added `#[cold]` + `#[inline(never)]` | | `vec2/raw_vec.rs` | `capacity_overflow` | Added `#[cold]` + `#[inline(never)]` | ### Impact The `#[cold]` attribute tells the compiler to: 1. Assume branches leading to these functions are unlikely 2. Move cold code away from hot paths (improves i-cache locality) 3. Avoid inlining cold functions into hot callers ## Test plan - [x] `cargo test -p oxc_allocator` passes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
0dd3702 to
46cd73d
Compare
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
#[cold]and#[inline(never)]annotations to error/panic functions in oxc_allocatorFunctions annotated
bump.rsallocation_size_overflow#[cold]bumpalo_alloc.rsnew_layout_err#[cold]+#[inline(never)]bumpalo_alloc.rshandle_alloc_error#[cold]+#[inline(never)]vec2/raw_vec.rscapacity_overflow#[cold]+#[inline(never)]Impact
The
#[cold]attribute tells the compiler to:Test plan
cargo test -p oxc_allocatorpasses🤖 Generated with Claude Code