[PATCH] malloc: Improve malloc initialization

Wilco Dijkstra Wilco.Dijkstra@arm.com
Tue Mar 25 00:30:58 GMT 2025


Hi DJ,

> Wilco Dijkstra <Wilco.Dijkstra@arm.com> writes:
>> Move malloc initialization out of hot paths - it is only required after checking
>> fastbins in _int_malloc or before tcache initialization. Bench-malloc-thread
>> improves by 1.8% for 1 thread and 1.3% for 32 threads on Neoverse V2.
>
> ptmalloc_init sets up the tunables needed to properly manage tcache and
> fastbins...

And that's fine because one can't enter tcache code when it has not been
initialized yet. The same is true for the fastbins - global_max_fast is zero
intialized, so we can't enter the fastbin case until initialization has been run.

Or would you prefer calling ptmalloc_init explicitly during startup?

Cheers,
Wilco


More information about the Libc-alpha mailing list