Repository navigation
Make ArenaVec a Vec over a std Allocator - #332
Closed
kevaundray wants to merge 1 commit into
Closed
kevaundray wants to merge 1 commit into
kevaundray wants to merge 1 commit into
Conversation
The `Allocator` trait, `Vec<T, A>` and `Box<T, A>` are stable from Rust 1.100 (rust-lang/rust#156882). `zk_alloc::Arena` is a zero-sized `Allocator` over `raw_alloc`/`raw_dealloc`, which already tell arena from system memory by address, and `ArenaVec<T>` is `Vec<T, Arena>`. The hand-written vector is gone and every `Vec` method works on an `ArenaVec`. - `Vec`'s constructors belong to the global allocator, so `new`, `with_capacity`, `from_slice`, `filled`, `zeroed`, `uninitialized` and `from_iter` move to an `ArenaVecExt` trait. `collect()`, `Default` and `mem::take` are unavailable for the same reason; four call sites use `from_iter` and `mem::replace` instead. - `primitives::multilinear::Shrink` only let the folds take either vector type. It is deleted and the folds are generic over `A: Allocator`, calling `truncate` (not `Vec::shrink_to`, which shrinks capacity). - An allocator's methods must never unwind. The address space was reserved lazily inside the first allocation behind an `assert!`; `enable_arena` now reserves it. - `clippy::uninit_vec` now sees two deliberate uninitialized vectors it could not see through the old type; each gets an `#[expect]` with its reason. Requires Rust 1.100 (nightly until it ships); stable 1.97 rejects `allocator_api`. Measured on x86-64 (32 threads), same nightly for both builds, alternating runs, proving time: fibonacci --n 2000000: base 1.864 s, 1.883 s; new 1.889 s, 1.923 s leanxmss --n 400: base 3.247, 3.275, 3.152 (±7.2%) s; new 3.284, 3.244, 3.248 s No difference beyond run-to-run noise; peak memory within 0.3%.
Collaborator
Author
|
CI fails because its not using nightly-1.100 |
Collaborator
Author
|
closing |
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.
This is an experiment to see what it would look like to adopt thw new allocator API that was standardised in nightly rust 1.100.
This is not meant to be merged, we can just wait for it to go onto stable.