[patch v3] malloc: avoid need for tcache == NULL checks
DJ Delorie
dj@redhat.com
Thu Sep 4 03:41:28 GMT 2025
Wilco Dijkstra <Wilco.Dijkstra@arm.com> writes:
> Previously we agreed not to initialize tcache on the free path, and instead let
> the first malloc initialize tcache.
That breaks the testsuite, unless we also add tcache_init to all the
memalign calls too.
> If we want to add initialization, it has to be a no-inline tailcall
> and should be placed after the tcache accesses as Florian points out.
Done.
> All this complexity is also why we should think of a way to completely get rid
> of this initialization. It continues to create performance and correctness issues
> only because we want to save ~512 bytes per thread...
760, but who's counting?
And that's per thread, not per thread that does allocation. That could
add up to a lot of cost to initialize a lot of unused data for each
short-lived computation-only thread, depending on the application.
More information about the Libc-alpha
mailing list