perf(allocator): per-platform Arena::new_fixed_size implementations#22088
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via 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. |
Merging this PR will not alter performance
Comparing Footnotes
|
Arena::new_fixed_size implementationsArena::new_fixed_size implementations
There was a problem hiding this comment.
Pull request overview
This PR refactors Arena::new_fixed_size into per-platform implementations to better handle very high alignment requirements (4 GiB) across macOS, Windows, and Linux, reducing unnecessary VM usage on Linux and avoiding Rust std’s Windows high-alignment workaround overhead.
Changes:
- Introduces a new
arena/fixed_size/module with OS-specificArena::new_fixed_sizeimplementations (macos,windows,linuxfallback). - Adjusts Windows fixed-size arena allocation to use a low-alignment backing allocation and manually select a 4 GiB-aligned sub-region.
- Updates CI workflow job/step gating (currently by commenting out
if:conditions).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
crates/oxc_allocator/src/arena/fixed_size/mod.rs |
Adds shared docs/invariants and dispatches to platform-specific implementations via cfg. |
crates/oxc_allocator/src/arena/fixed_size/macos.rs |
Uses 2 GiB-aligned over-allocation strategy to obtain a 4 GiB-aligned chunk on macOS. |
crates/oxc_allocator/src/arena/fixed_size/windows.rs |
Uses a 16-byte-aligned over-allocation and manual pointer rounding to a 4 GiB boundary on Windows. |
crates/oxc_allocator/src/arena/fixed_size/linux.rs |
Requests the desired BLOCK_SIZE + BLOCK_ALIGN directly (and acts as the non-macOS/non-Windows fallback). |
.github/workflows/ci.yml |
Comments out multiple if: conditions, making many jobs/steps run unconditionally. |
Comments suppressed due to low confidence (1)
crates/oxc_allocator/src/arena/fixed_size/macos.rs:63
- The safety comment says “We allocated 4 GiB of memory”, but the actual allocation is
ALLOC_SIZE = BLOCK_SIZE + TWO_GIB(4 GiB - 16). Since this is part of the unsafe reasoning, it should describe the precise size/in-bounds argument (or referenceALLOC_SIZE) to avoid future confusion.
9aefd50 to
a636cb8
Compare
e0da555 to
6900042
Compare
a636cb8 to
40fa8b5
Compare
Merge activity
|
…#22088) Introduce separate `Arena::new_fixed_size` implementations for different platforms. Different platforms have differing abilities to service allocation requests with high alignment, so a different allocation strategy is appropriate for each: - Mac OS: System allocator refuses 4 GiB-aligned allocation requests. Allocate ~4 GiB with 2 GiB alignment, then use either the top or bottom half for the arena chunk. - Windows: System allocator cannot service allocations with any alignment over 16. Allocate ~6 GiB with 16 alignment, and then find a ~2 GiB block within that allocation which is aligned on 4 GiB. This is what `std` was doing already, but implementing it ourself sidesteps an annoyance with `std`'s implementation. - Linux: System allocator can service high-alignment requests, so just ask for exactly what we want (~2 GiB with 4 GiB alignment). This reduces virtual memory usage on Linux, side-steps `std`'s workaround on Windows, and is unchanged for Mac OS. This also prepares the way for using `VirtualAlloc`\-based allocation on Windows, to avoid committing large amounts of memory - the cause of OOM problems in Oxlint with JS plugins on Windows (#19395).
6900042 to
94040ce
Compare
40fa8b5 to
0bf0cb9
Compare
### 💥 BREAKING CHANGES - 0ffbe0d allocator: [**BREAKING**] Remove `Allocator::end_ptr` method (#21871) (overlookmotel) ### 🚀 Features - 9593ec8 transformer/jsx: Add jsxDEV source metadata for fragments (#21932) (Ido Rosenthal) ### 🐛 Bug Fixes - 429deac napi/parser: Export `visitorKeys` from `wasm` entrypoint (#21996) (NullVoxPopuli) - e852911 codegen: Preserve legal comments orphaned by upstream passes (#21575) (Dunqing) - e3399ec transformer/class-properties: Preserve RHS in logical-assignment to static private field (#21950) (Dunqing) - c59c199 transformer/typescript: Emit class fields for parameter properties (#21831) (Dunqing) - aaabde4 parser: Attach legal comments to following token (#21670) (Dunqing) ### ⚡ Performance - 0bf0cb9 allocator: Per-platform `Arena::new_fixed_size` implementations (#22088) (overlookmotel) ### 📚 Documentation - 62ec410 allocator: Correct doc comment for `Allocator::from_raw_parts` (#22093) (overlookmotel) - 3e152c6 allocator: Correct typos in comments (#22092) (overlookmotel) - e220855 allocator: Correct doc comment for `Allocator::set_cursor_ptr` (#21866) (overlookmotel) --------- Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com> Co-authored-by: Cameron Clark <cameron.clark@hey.com>

Introduce separate
Arena::new_fixed_sizeimplementations for different platforms.Different platforms have differing abilities to service allocation requests with high alignment, so a different allocation strategy is appropriate for each:
stdwas doing already, but implementing it ourself sidesteps an annoyance withstd's implementation.This reduces virtual memory usage on Linux, side-steps
std's workaround on Windows, and is unchanged for Mac OS.This also prepares the way for using
VirtualAlloc-based allocation on Windows, to avoid committing large amounts of memory - the cause of OOM problems in Oxlint with JS plugins on Windows (#19395).