Skip to content

perf(allocator): add #[cold] to to error handling functions#20967

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/04-02-perf_allocator_add_cold_to_to_error_handling_functions
Apr 2, 2026
Merged

perf(allocator): add #[cold] to to error handling functions#20967
graphite-app[bot] merged 1 commit intomainfrom
om/04-02-perf_allocator_add_cold_to_to_error_handling_functions

Conversation

@overlookmotel
Copy link
Copy Markdown
Member

@overlookmotel overlookmotel commented Apr 2, 2026

Repeat of #18181.

#20963 wiped all changes to bumpalo_alloc.rs, going back to a fresh copy of bumpalo. Re-apply changes from #18181 which were lost in the process - marking error handling functions as #[cold].

This PR differs from #18181 in one minor respect. new_layout_err is not marked #[inline(never)] in this PR. The function is a no-op (unconditionally returns a ZST), so we do want it inlined, but with the#[cold]attribute to hint to compiler that it's a cold path.

Copy link
Copy Markdown
Member Author

overlookmotel commented Apr 2, 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.

@github-actions github-actions Bot added the C-performance Category - Solution not expected to change functional behavior, only performance label Apr 2, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 2, 2026

Merging this PR will not alter performance

✅ 48 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing om/04-02-perf_allocator_add_cold_to_to_error_handling_functions (f341b81) with om/04-02-docs_allocator_data_structures_correct_comments (3e04edd)2

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.

  2. No successful run was found on om/04-02-docs_allocator_data_structures_correct_comments (ddd06ac) during the generation of this report, so 565a1cb was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@overlookmotel overlookmotel marked this pull request as ready for review April 2, 2026 13:50
Copilot AI review requested due to automatic review settings April 2, 2026 13:50
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

Re-applies the previously lost allocator performance tweak by marking allocation error paths as cold, helping the compiler keep hot allocation code better laid out.

Changes:

  • Mark new_layout_err as #[cold] to bias Layout::repeat overflow/error paths as unlikely.
  • Mark handle_alloc_error as #[cold] + #[inline(never)] to keep panic/abort code out of hot paths.

@overlookmotel overlookmotel force-pushed the om/04-02-perf_allocator_add_cold_to_to_error_handling_functions branch from 59ab6d8 to f341b81 Compare April 2, 2026 14:55
@overlookmotel overlookmotel force-pushed the om/04-02-docs_allocator_data_structures_correct_comments branch from 3e04edd to ddd06ac Compare April 2, 2026 14:55
@overlookmotel overlookmotel self-assigned this Apr 2, 2026
@overlookmotel overlookmotel added the A-allocator Area - Allocator label Apr 2, 2026
@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Apr 2, 2026 — with Graphite App
@graphite-app
Copy link
Copy Markdown
Contributor

graphite-app Bot commented Apr 2, 2026

Merge activity

Repeat of #18181.

#20963 wiped all changes to `bumpalo_alloc.rs`, going back to a fresh copy of `bumpalo`. Re-apply changes from #18181 which were lost in the process - marking error handling functions as `#[cold]`.

This PR differs from #18181 in one minor respect. `new_layout_err` is not marked `#[inline(never)]` in this PR. The function is a no-op (unconditionally returns a ZST), so we do want it inlined, but with the`#[cold]`attribute to hint to compiler that it's a cold path.
@graphite-app graphite-app Bot force-pushed the om/04-02-docs_allocator_data_structures_correct_comments branch from ddd06ac to b1da750 Compare April 2, 2026 15:11
@graphite-app graphite-app Bot force-pushed the om/04-02-perf_allocator_add_cold_to_to_error_handling_functions branch from f341b81 to cbc0c21 Compare April 2, 2026 15:11
@graphite-app graphite-app Bot removed the 0-merge Merge with Graphite Merge Queue label Apr 2, 2026
Base automatically changed from om/04-02-docs_allocator_data_structures_correct_comments to main April 2, 2026 15:17
@graphite-app graphite-app Bot merged commit cbc0c21 into main Apr 2, 2026
28 checks passed
@graphite-app graphite-app Bot deleted the om/04-02-perf_allocator_add_cold_to_to_error_handling_functions branch April 2, 2026 15:18
leaysgur pushed a commit that referenced this pull request Apr 7, 2026
### 🐛 Bug Fixes

- fc7f60c allocator: Revert changes to
`get_current_chunk_footer_field_offset` (#20964) (overlookmotel)
- 31316c8 semantic: Rebind class expressions before identifier checks
(#20916) (camc314)

### ⚡ Performance

- fb52383 napi/parser, linter/plugins: Clear buffers and source texts
earlier (#21025) (overlookmotel)
- 3b7dec4 napi/parser, linter/plugins: Use `utf8Slice` for decoding
UTF-8 strings (#21022) (overlookmotel)
- 012c924 napi/parser, linter/plugins: Speed up decoding strings in raw
transfer (#21021) (overlookmotel)
- 55e1e9b napi/parser, linter/plugins: Initialize vars as 0 (#21020)
(overlookmotel)
- c25ef02 napi/parser, linter/plugins: Simplify branch condition in
`deserializeStr` (#21019) (overlookmotel)
- 9f494c3 napi/parser, linter/plugins: Raw transfer use
`String.fromCharCode` in string decoding (#21018) (overlookmotel)
- 91cf105 allocator: Increase initial chunk size from 512B to 16KB
(#20968) (overlookmotel)
- cbc0c21 allocator: Add `#[cold]` to to error handling functions
(#20967) (overlookmotel)
- 0503a78 napi/parser, linter/plugins: Faster deserialization of `raw`
fields (#20923) (overlookmotel)
- a24f75e napi/parser: Optimize string deserialization for non-ASCII
sources (#20834) (Joshua Tuddenham)

### 📚 Documentation

- c78a57a syntax: Fix typo (#21044) (camc314)
- f5e228f allocator: Fix typo in comment (#20972) (overlookmotel)
- 7159d51 allocator: Improve doc comment examples for `vec2::Vec`
(#20969) (overlookmotel)
- b1da750 allocator, data_structures: Correct comments (#20966)
(overlookmotel)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-allocator Area - Allocator 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