[PATCH] malloc: fix large tcache code to check for exact size match

Wilco Dijkstra Wilco.Dijkstra@arm.com
Tue Oct 21 14:46:01 GMT 2025


Hi Cupertino,

> Wilco: Would the patch below be a better solution, performance wise?
> I would assume so, since all those functions would get inline anyway,
> but maybe I am missing the reason for the performance degradation.

>     if ((mangled && REVEAL_PTR (*entry) == NULL)
> -      || (!mangled && *entry == NULL))
> +      || (!mangled && *entry == NULL)
> +      || (nb != chunksize (mem2chunk (te))))
>         return NULL;

That should be te == NULL || nb != chunksize (mem2chunk (te)).
With that the optimized difference is 1% rather than 4.5%, which is much
better. We can still do better but it requires simplifying these functions
by inlining them into each other.

Cheers,
Wilco




More information about the Libc-alpha mailing list