[PATCH] malloc: Use correct C11 atomics for fastbin

Wilco Dijkstra Wilco.Dijkstra@arm.com
Tue Dec 6 13:29:09 GMT 2022


Hi,

On 2022-12-02 1:55 PM, DJ Delorie via Libc-alpha wrote:
>> Wilco Dijkstra <Wilco.Dijkstra@arm.com> writes:
>>> If we want to make tcache actually work, it will have to support far more
>>> allocations, particularly for smaller sizes.
>> 
>> You can test that with a tunable; the max count per bin is runtime
>> tunable.

Yes you can use tunables, but how many applications actually use more
optimized settings? It's the default that is the problem.

>> But yeah, the point of tcache is to have a few of many sizes for fast
>> allocations.  Fastbins has a lot of a few small sizes.  Testing showed
>> that both were required for best performance with the average
>> application.

Yes, that's due the tiny size of tcache (let's call it tiny-cache!). Once exhausted,
you mostly end up using the fastbins.

> Every time we start talking about fastbins vs tcache again I start 
> wondering, again, what's stopping us from replacing the entire malloc 
> implementation with jemalloc, or any other implementation designed less 
> than 20 years ago.

I can't see any technical reason why not. It's either that or completely rewriting
the current implementation and getting rid of decades of accumulated cruft...

Modern allocators are not only much faster than GLIBC in their default settings
but also have lower memory usage. The two best allocators seem to be mimalloc
and jemalloc.

Cheers,
Wilco


More information about the Libc-alpha mailing list