refactor(allocator): inline bumpalo into oxc_allocator#18168
refactor(allocator): inline bumpalo into oxc_allocator#18168graphite-app[bot] merged 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR inlines the bumpalo v3.19.0 bump allocator directly into oxc_allocator to gain full control over the arena allocator implementation for future optimizations. The ported code is kept exactly as-is with lint allows added to preserve the original implementation.
Changes:
- Adds
bump.rsandbumpalo_alloc.rsmodules with the complete bump allocator implementation from bumpalo v3.19.0 - Updates all imports across the crate to use
crate::bump::Bumpinstead ofbumpalo::Bump - Removes the bumpalo dependency from workspace and crate-level Cargo.toml files
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/oxc_allocator/src/bump.rs | Ports the main Bump allocator implementation with ~2067 lines including tests |
| crates/oxc_allocator/src/bumpalo_alloc.rs | Ports the Alloc trait and related memory allocation types (~800 lines) |
| crates/oxc_allocator/src/lib.rs | Declares the new internal modules as pub(crate) |
| crates/oxc_allocator/src/allocator.rs | Updates import from external bumpalo to internal bump module |
| crates/oxc_allocator/src/alloc.rs | Updates import and uses qualified method calls to avoid ambiguity |
| crates/oxc_allocator/src/allocator_api2.rs | Updates comments and uses qualified method calls for clarity |
| crates/oxc_allocator/src/vec.rs | Updates import to use internal bump module |
| crates/oxc_allocator/src/tracking.rs | Updates import to use internal bump module |
| crates/oxc_allocator/src/hash_map.rs | Updates import to use internal bump module |
| crates/oxc_allocator/src/hash_set.rs | Updates import to use internal bump module |
| crates/oxc_allocator/src/from_raw_parts.rs | Updates import and replaces Bump::<1>::with_min_align() with Bump::new() |
| crates/oxc_allocator/src/vec2/raw_vec.rs | Updates test import to use internal bump module |
| crates/oxc_allocator/Cargo.toml | Removes bumpalo dependency |
| Cargo.toml | Removes bumpalo dependency with explanatory comment |
| Cargo.lock | Updates dependency tree (bumpalo still present for wasm-bindgen) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
CodSpeed Performance ReportMerging this PR will not alter performanceComparing Summary
Footnotes
|
Merge activity
|
## Summary - Port bumpalo v3.19.0 directly into `oxc_allocator` as internal modules - Add `bump.rs` with the Bump allocator implementation - Add `bumpalo_alloc.rs` with the Alloc trait and related types - Update all imports to use internal `crate::bump::Bump` - Remove bumpalo dependency from workspace and crate This gives us full control over the arena allocator implementation for future optimizations. The ported code is kept exactly as-is from bumpalo with lint allows added to preserve the original implementation. ## Test plan - [x] `cargo test -p oxc_allocator` - all 26 unit tests pass - [x] `cargo clippy -p oxc_allocator --all-features` - no warnings 🤖 Generated with [Claude Code](https://claude.com/claude-code)
5e07770 to
16d5906
Compare
## Summary Now that bumpalo has been inlined into oxc_allocator (#18168), this PR cleans up comments and documentation that still reference bumpalo as an external dependency. - Update module docs in `bump.rs` and `bumpalo_alloc.rs` to say "originally derived from" instead of "ported from" - Remove obsolete comments about bumpalo version pinning in `from_raw_parts.rs` - Update inline comments in `allocator.rs` from "delegates to bumpalo" to "it's a small function" - Remove outdated TODO about replacing bumpalo in `tracking.rs` - Update `ARCHITECTURE.md` and parser docs to reference `oxc_allocator` instead of bumpalo - Clean up bumpalo references in other crates (`oxc_semantic`, `oxc_data_structures`, `apps/oxlint`, `napi/parser`, `tasks/ast_tools`) ## Test plan - [x] `cargo check -p oxc_allocator` passes - [x] `cargo test -p oxc_allocator` passes - [x] Changes are documentation/comment only - no functional changes 🤖 Generated with [Claude Code](https://claude.ai/code)
## Summary Now that bumpalo has been inlined into oxc_allocator (#18168), this PR cleans up comments and documentation that still reference bumpalo as an external dependency. - Update module docs in `bump.rs` and `bumpalo_alloc.rs` to say "originally derived from" instead of "ported from" - Remove obsolete comments about bumpalo version pinning in `from_raw_parts.rs` - Update inline comments in `allocator.rs` from "delegates to bumpalo" to "it's a small function" - Remove outdated TODO about replacing bumpalo in `tracking.rs` - Update `ARCHITECTURE.md` and parser docs to reference `oxc_allocator` instead of bumpalo - Clean up bumpalo references in other crates (`oxc_semantic`, `oxc_data_structures`, `apps/oxlint`, `napi/parser`, `tasks/ast_tools`) ## Test plan - [x] `cargo check -p oxc_allocator` passes - [x] `cargo test -p oxc_allocator` passes - [x] Changes are documentation/comment only - no functional changes 🤖 Generated with [Claude Code](https://claude.ai/code)
#18168 copied `bumpalo`'s code for `Bump` into `oxc_allocator` crate. #18172, #18181, and #18234 made a few improvements to the implementation. However, #18168 removed various things, and altered others. Notably, it removed the`MIN_ALIGN` generic param, which we definitely want to keep. I'm going to be working on the allocator, and would like to start with a clean slate, beginning with the "known good" implementation of `bumpalo`. This PR removes the previous modified `bumpalo` implementation, and copies latest version of `bumpalo` from main branch into the repo. It then makes the absolute minimum changes necessary just to make CI pass. Note: Unlike #18168, this PR keeps all the doctests for `Bump`, using a trick of adding the crate to it's own `dev-dependencies` with `testing` feature enabled, and exposing `Bump` only with that feature. This PR is broken into multiple commits, so we have an exact "trail of breadcrumbs" of how we've diverged from `bumpalo`. I intend to manually merge this PR, so that record remains on Github (instead of Graphite squashing all the commits). Later PRs in this stack reapply the changes made in #18172, #18181, and #18234 on top of the fresh base implementation. This PR is a small perf regression, but that will be won back once those other changes are reapplied.
…set` (#20964) Partial revert of #18168. #18168 made a small change to `get_current_chunk_footer_field_offset` (used by `Allocator::from_raw_parts`). That change was correct in the context of the other changes made to `Bump` in that PR, but now that #20963 has rolled back most of those changes, this change needs to be reverted too as it's a potential perf regression with current version of `Bump`.
Follow-on after #18168. With the removal of `bumpalo` dependency, the examples in doc comments in `vec2::Vec` would no longer compile. That PR marked them all as `text` to prevent them running as doctests. Change them to `ignore` instead. That's preferable as it at least makes sure they're valid Rust syntax.
Summary
oxc_allocatoras internal modulesbump.rswith the Bump allocator implementationbumpalo_alloc.rswith the Alloc trait and related typescrate::bump::BumpThis gives us full control over the arena allocator implementation for future optimizations. The ported code is kept exactly as-is from bumpalo with lint allows added to preserve the original implementation.
Test plan
cargo test -p oxc_allocator- all 26 unit tests passcargo clippy -p oxc_allocator --all-features- no warnings🤖 Generated with Claude Code