2 ms·
Is heap allocation actually unavoidable? PHP uses an arena allocator for its AST. I don't know how applicable that could be to Rust.
by TazeTSchnitzel 10y ago
Is heap allocation actually unavoidable? PHP uses an arena allocator for its AST. I don't know how applicable that could be to Rust.
- hackcrafter 10y agoNot that applicable. Rust memory model around strong ownership and borrow-checking differs from the GC languages that can use generational strategies and lots of heap allocation re-use. All languages are doing allocations to the OS, rust just doesn't have a GC like PHP does to intermediate.
- TazeTSchnitzel 10y agoPHP's compiler is written in C, and its AST isn't garbage-collected. I think we just throw out the entire arena, actually.
- slededit 10y agoTechnically its a very limited form of garbage collection... Then again with this definition so is just not free-ing anything and letting the OS cleanup after process exit.
- TazeTSchnitzel 10y agoI believe it's manually freed.
- rkangel 10y agoThere are plenty of things that could be used to speed up particular hotspots - arena allocators are one option. Better than that is to not allocate at all, which is the focus of the effort here. A step further down the line of optimisation may identify allocation hotspots and use custom allocation strategies rather than using the language default (the heap).
- Manishearth 10y agoRust uses an arena for the type graph as well. Note that jemalloc gets you a lot of the benefits of using an arena for free.