Skip to content

refactor(allocator): clarify max calculations in Arena#21796

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/04-26-refactor_allocator_clarify_max_calculations_in_arena_
Apr 26, 2026
Merged

refactor(allocator): clarify max calculations in Arena#21796
graphite-app[bot] merged 1 commit intomainfrom
om/04-26-refactor_allocator_clarify_max_calculations_in_arena_

Conversation

@overlookmotel
Copy link
Copy Markdown
Member

@overlookmotel overlookmotel commented Apr 26, 2026

Small refactor to Arena. Use cmp::max(a, b) instead of the chained version a.max(b). I find the former clearer.

Also simplify one max operation (see comment in code).

Copy link
Copy Markdown
Member Author

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

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

Refactors oxc_allocator::arena::Arena alignment/size calculations to use std::cmp::max consistently and simplifies one chunk-alignment computation based on the existing MIN_ALIGN <= CHUNK_ALIGN invariant.

Changes:

  • Replace chained .max(...) calls with cmp::max(a, b) across allocator code and tests.
  • Simplify new_chunk alignment computation to only consider requested_layout.align() and CHUNK_ALIGN.
  • Update an arena allocation test to use cmp::max for alignment expectations.

Reviewed changes

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

File Description
crates/oxc_allocator/tests/arena/alloc_fill.rs Updates test alignment math to use cmp::max.
crates/oxc_allocator/src/arena/create.rs Uses cmp::max and simplifies chunk alignment calculation in new_chunk.
crates/oxc_allocator/src/arena/alloc_impl.rs Switches size/alignment max computations to cmp::max.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 26, 2026

Merging this PR will not alter performance

✅ 48 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing om/04-26-refactor_allocator_clarify_max_calculations_in_arena_ (94a41eb) with om/04-26-refactor_allocator_combine_arena_new_chunk_memory_details_into_arena_new_chunk_ (481b75f)

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 force-pushed the om/04-26-refactor_allocator_combine_arena_new_chunk_memory_details_into_arena_new_chunk_ branch from b56ad4b to 0423be8 Compare April 26, 2026 21:15
@overlookmotel overlookmotel force-pushed the om/04-26-refactor_allocator_clarify_max_calculations_in_arena_ branch from 87e8340 to 8fb23df Compare April 26, 2026 21:15
@graphite-app
Copy link
Copy Markdown
Contributor

graphite-app Bot commented Apr 26, 2026

Merge activity

Small refactor to `Arena`. Use `cmp::max(a, b)` instead of the chained version `a.max(b)`. I find the former clearer.

Also simplify one `max` operation (see comment in code).
@graphite-app graphite-app Bot force-pushed the om/04-26-refactor_allocator_combine_arena_new_chunk_memory_details_into_arena_new_chunk_ branch from 0423be8 to 481b75f Compare April 26, 2026 21:53
@graphite-app graphite-app Bot requested a review from camc314 as a code owner April 26, 2026 21:53
@graphite-app graphite-app Bot force-pushed the om/04-26-refactor_allocator_clarify_max_calculations_in_arena_ branch from 8fb23df to 94a41eb Compare April 26, 2026 21:54
Base automatically changed from om/04-26-refactor_allocator_combine_arena_new_chunk_memory_details_into_arena_new_chunk_ to main April 26, 2026 22:13
@graphite-app graphite-app Bot merged commit 94a41eb into main Apr 26, 2026
38 checks passed
@graphite-app graphite-app Bot deleted the om/04-26-refactor_allocator_clarify_max_calculations_in_arena_ branch April 26, 2026 22:14
@overlookmotel overlookmotel added A-allocator Area - Allocator C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-allocator Area - Allocator C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants