[PATCH v4 3/7] malloc: replace _int_free by _int_free_chunk in sysmalloc.

Cupertino Miranda cupertino.miranda@oracle.com
Mon Mar 17 11:45:29 GMT 2025


Hi DJ,

On 14-03-2025 23:49, DJ Delorie wrote:
> Cupertino Miranda <cupertino.miranda@oracle.com> writes:
>> sysmalloc calls to _int_free should not allow the freed chunks to be
>> taken by tcache. These internal calls to free do not reflect any of the
>> needs of the application, but rather chunk management.
> 
> The idea hwere is to pre-load tcache if/when we happen across chunks the
> right size.  
Right, it makes sense. I understood the benefit for the original code.

> Are you saying here that only saving chunks the application
> free's is overall faster than pre-loading the cache?

This was rather a solution to not allow to cache all chunks that would 
not be related to actual frees from within the application.
When you only freeing chunks to size up to ~1k, that is not problematic 
at all, but once above that limit (as enabled in patch 4) it is rather 
not useful, since it is unlikely that the application will request a 
chunk of a similar size.
Allowing to cache larger chunks is not beneficial for the majority of 
applications. It is rather only useful for many thread applications that 
would often reallocate larger data chunks of the same size. That is the 
reason why it is only enabled with a tunable.

I think this patch actually fixes some errors in testsuite once I 
enabled larger chunk caching from patch 4.

Cheers,
Cupertino


More information about the Libc-alpha mailing list