#I want to leak memory fast

19 messages · Page 1 of 1 (latest)

rustic arrow
#

My one-shot program generates long-lived shared immutable data over time, a perfect opportunity for a global/static arena allocator.
Is there a better way to do this than a thread_local! lazy_static! bumpalo::Bump?

somber kernel
#

How about Box::leak?

rustic arrow
#

Arena allocation is faster

light blaze
#

std::mem::forget ferrisHotTake

rustic arrow
#

Anecdotally DMD got an overall wall-clock 2x speedup by switching from the equivalent of Box::leak to arena allocation

rustic arrow
#

sorry, not sure I understand 😅

#

I've never used once_cell before, how would I use it here?

light blaze
vagrant vigil
#

this is a work for C++

quiet lichen
#

I don't think you can be faster than putting an arena in a static and querying data from it

rustic arrow
#

Yes, that is what I want to do :P

#

I am just asking about the simplest way to do it (like if there are libraries that make it easy)

#

there was so much library plumbing for thread_local! lazy_static! bumpalo::Bump that I just wrote a simple arena allocator myself

#

but it would be very nice if there were a crate that did what I want bc then it wouldn't be my job to worry about safety properties

alpine sapphire
rustic arrow
#

I was going to but changed my mind, deleted the dependencies, and just wrote the arena myself

alpine sapphire
#

thread_local! and lazy_static! aren't supposed to be used at once, what does your code look like now?

rustic arrow
#

TIL, thanks