[PATCH v2] malloc: move tcache_init out of hot tcache paths
Wilco Dijkstra
Wilco.Dijkstra@arm.com
Tue Apr 15 15:32:10 GMT 2025
Hi Cupertino,
> @@ -3433,6 +3434,8 @@ __libc_malloc (size_t bytes)
>
> if (tcache_available (tc_idx))
> return tag_new_usable (tcache_get (tc_idx));
>+ else
>+ MAYBE_INIT_TCACHE ();
>#endif
>
> return __libc_malloc2 (bytes);
It still has this which slows down malloc by adding a call. There is another issue with
moving tcache initialization earlier: malloc is initialized in __libc_malloc2, so tcache
will now be initialized before it - however tcache assumes malloc has been initialized
before it...
> @@ -3474,8 +3477,6 @@ __libc_free (void *mem)
> }
> else
> {
> - MAYBE_INIT_TCACHE ();
> -
On latest trunk this has now moved to _int_free_chunk. We could also remove the errno
save/restore from tcache_init since it's only there because of the above line.
Cheers,
Wilco
More information about the Libc-alpha
mailing list