This allocator is fast, small, and specific to WebAssembly. In the future, this will be the implementation automatically selected by GeneralPurposeAllocator when compiling in ReleaseSmall mode for wasm32 and wasm64 architectures. Until then, it is available here to play with.
It’s past time to make that foreshadowed change - the compiler has been using this allocator when building from source for 1.5 years now, autodocs uses it since my rewrite, and I’ve been using it in a personal project. It’s tried and true at this point.
Been using this wasm allocator in my current Zig/Wasm project, works great whereas the standard gpa allocator throws warnings and evetually assertion fails in some cases.
Auto selection refactor sounds neat, although it’s pretty nice to actually be able to pick that allocator manually. Fits the no hidden flow/stuff/make your own allocator Zig vibe.
So would be great to either merge or remove the “in the future” comment altogether yeah
…just as a side note, in my home computer emulator project the ReleaseSmall mode is massively slower than both ReleaseFast and ReleaseSafe (about half the performance of both Fast and Safe).
When I checked the compiler output, this is because the compiler was aggressively outlining identical code snippets from a big switch-based CPU instruction decoder into function calls, and this totally destroyed performance.
E.g.: I’d still want to be able to use a small allocator on WASM even when not compiling with ReleaseSmall In my code, allocator performance doesn’t matter (since I allocate only very infrequently, and mostly at startup), but code size does.