[PATCH] malloc: Improve performance of __libc_calloc

DJ Delorie dj@redhat.com
Tue May 13 03:16:00 GMT 2025


Wilco Dijkstra <Wilco.Dijkstra@arm.com> writes:

> Improve performance of __libc_calloc by splitting it into 2 parts: first handle
> the tcache fastpath, then do the rest in a separate tailcalled function.
> This results in significant performance gains since __libc_calloc doesn't need
> to setup a frame.
>
> On Neoverse V2, bench-calloc-simple improves by 5.0% overall. Bench-calloc-tcache 32
> improves by 24%.
>
> Regress passed, OK for commit?

I have two comments:

1. It no longer applies due to your removal of initialization code in
   your previous patch.  Looks like a trivial rebase.

2. "sz" changes type from INTERNAL_SIZE_T to size_t.  At the moment this
   doesn't matter because those types are the same on all supported
   targets, but we allow a configuration to have 64-bit size_t but
   32-bit INTENRAL_SIZE_T to save memory.  This should at least be
   addressed.

The rest of the code looks OK to me, please post a v2 that's applyable
(for the record) and ponder if we care about #2 above.



More information about the Libc-alpha mailing list