Remix.run Logo
Jarred 21 hours ago

Grouped and arena allocations work really well in Zig. For awhile, we tried to use this pattern almost everywhere in Bun but it gets really tricky when there’s some GC-managed memory and you want to free things incrementally to reduce RSS. Also, using arenas for arrays that grow wastes memory a lot since it keeps every previous version around (mimalloc arenas are slightly better for this)

Grouped allocations works especially well in parsers & ASTs where the lifetime is very bounded. Since the Rust rewrite, we still use arenas for Bun’s parsers and the bundler but not a ton elsewhere.

HexDecOctBin 16 hours ago | parent [-]

> using arenas for arrays that grow wastes memory a lot since it keeps every previous version around

Not if you use segmented arrays

https://danielchasehooper.com/posts/segment_array/