I wonder how this compares to jemalloc, mimalloc, snmalloc?
I never got a chance to compare it to those, since I was most interested in beating bmalloc. And I mainly wanted to beat it on Safari workloads. I believe bmalloc was previously compared against jemalloc and tcmalloc, also using Safari workloads, and bmalloc was significantly faster at the time.
All About Libpas, Phil's Super Fast Malloc
81–87 of 87 posts
Re: All About Libpas, Phil's Super Fast Malloc
#82Re: All About Libpas, Phil's Super Fast Malloc
#83I wonder how this compares to jemalloc, mimalloc, snmalloc?
Re: All About Libpas, Phil's Super Fast Malloc
#84I admit I'm a sucker for metacircularity, but have to ask: > The bootstrap heap has hacks to allow itself to allocate that array out of itself. Not quite following that, can someone elaborate?
The bootstrap heap has a freelist that is just an array of entries that tell you where the free memory is. That array has to be allocated somewhere. All pas_simple_large_free_heaps allocate that array from the bootstrap heap. Including the bootstrap heap. So, the pas_simple_large_free_heap has hacks that go something like: "if I'm allocating or freeing something and I need to allocate or free the free list, then very…
Re: All About Libpas, Phil's Super Fast Malloc
#85pas stands for "Phil's Awesome System" though, not Phil's Superfast AS
Re: All About Libpas, Phil's Super Fast Malloc
#86Earlier quoted context omitted.
Its very easy to beat the general purpose ones if you know your exact use case. Ex: 16-bit pointers is a 65536-sized heap. Assume 8-bytes per element, that's 512KB of space. A bit small, but large enough to so a lot of things. 65536 elements can be represented as a bitmask. The bitmask only takes up 8192-bytes (8KB), which fits inside of 16 AVX512 registers (Intel offers 32x AVX512/ZMM registers btw). Or it fits insi…
512 in AVX512 is the number of bits per register. You are off by factor of 8.
Re: All About Libpas, Phil's Super Fast Malloc
#87Are there any projects that surgically augment the memory APIs to be more cooperative? Sure `malloc` implementations will make various tradeoffs, but what if the malloc/free APIs were expanded to expose more programmer-intent or cooperative defrag, etc? - Perhaps `malloc` could ask for an intended lifecycle (think GC generation) that could swap arenas or other algo internals. This opens us up to meta-allocators. - Pe…
I've thought about this a lot. I think that overall, malloc/free/new/delete are already so hard to use that if you added more stuff, it would create too much cognitive load for the programmer. The result would be that the hints the programmer gave you would be more wrong than the malloc's best guess. Let me go through these point by point and offer some thoughts. - Perhaps `malloc` could ask for an intended lifecycle…
Basically, just write assuming GC, then whereever a hint could possibly exist, throw computers at it. If anything, such hints should live outside the source code and have no semantic impact (i.e. program works fine if you throw it out).