Comments (3)
Come to think of it, if we've allocated 4 GiB originally and the max size of the bump is 4 GiB, then the bump can only ever require 1 chunk, and further branches can be removed.
Can this be right???
from bumpalo.
When
Bump
allocates a chunk from global allocator, request a chunk of 4 GiB size. If my understanding is correct, this will only consume 4 GiB of virtual memory, not physical memory (though I may be wrong about that, in which case my whole theory here collapses!)
Two things:
-
This is correct if the code is running on a system with virtual memory. That isn't guaranteed and
bumpalo
doesn't require that. Notably, Wasm doesn't have virtual memory. -
This would put us in the position of needing to (or at least being pressured to) manage virtual memory and detect when we can
madvise
away pages that we made physical mappings for because we touched them earlier, but then we did areset
.
Do you think this would work? And if so, would it be a worthwhile optimization?
I think this kind of thing is very valid for a bump allocation library to do, but it is also making a trade off to be more focused on a particular environment and use case and less general purpose. For that reason I don't think it is the right choice for this library.
from bumpalo.
But yeah, once you accept virtual memory, you don't even need to explicitly check against the end of the bump region. You just have a guard page just after (before, when bumping downwards) the end of the bump region and then check that sizeof(T) < sizeof(page)
which should be constant propagated away 99.99% of the time. Then you have a branch-free allocation path and when you run out of capacity you attempt to write to the guard page and then that raises a signal and you catch that and return allocation failure.
from bumpalo.
Related Issues (20)
- Miri Stacked Borrows violation after replacing `std::boxed::Box` with `bumpalo::boxed::Box`
- When can we expect a new release? HOT 1
- feat: expose constant ABOUT_ONE_PAGE or similar HOT 6
- MSRV build is broken HOT 2
- May panic due to unwrap on Err HOT 2
- Missing Clone for Box HOT 2
- Add rust-version to Cargo.toml HOT 1
- Request to yank bumpalo v3.12.1 HOT 1
- Implement `std::io::Write` for `Vec<'bump, u8>` HOT 1
- Add a `bumpalo::collections::ThinSlice` type HOT 1
- Memory leak may happen after calling `Bump::dealloc`. HOT 2
- `Box::pin_in` violates pin's drop guarantee HOT 1
- `allocator_api` tests failing HOT 2
- Improve performance of `extend_from_slice` where `T: Copy` HOT 4
- Ability to create Bump from pre-existing memory allocation? HOT 9
- MSRV disagrees between Cargo.toml and CHANGELOG.md HOT 2
- Minimum alignment HOT 3
- Analysis of Bump Allocator Performance HOT 1
- `Bump` not respecting allocation limit set HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bumpalo.