[PATCH] realloc: Limit chunk reuse to only growing requests [BZ #30579]
Siddhesh Poyarekar
siddhesh@sourceware.org
Wed Jul 5 14:37:17 GMT 2023
On 2023-07-05 07:55, Aurelien Jarno wrote:
> Hi,
>
> On 2023-07-04 14:24, Siddhesh Poyarekar via Libc-alpha wrote:
>> The trim_threshold is too aggressive a heuristic to decide if chunk
>> reuse is OK for reallocated memory; for repeated small, shrinking
>> allocations it leads to internal fragmentation and for repeated larger
>> allocations that fragmentation may blow up even worse due to the dynamic
>> nature of the threshold.
>>
>> Limit reuse only when it is within the alignment padding, which is 2 *
>> size_t for heap allocations and a page size for mmapped allocations.
>> There's the added wrinkle of THP, but this fix ignores it for now,
>> pessimizing that case in favor of keeping fragmentation low.
>>
>> This resolves BZ #30579.
>>
>> Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
>> Reported-by: Nicolas Dusart <nicolas@freedelity.be>
>> Reported-by: Aurelien Jarno <aurelien@aurel32.net>
>> ---
>>
>> The test case in the bz seems fixed with this, bringing VSZ and RSS back
>> to ~40M from ~1G. Aurelien, can you please test with plasma desktop?
>
> Thanks for the quick fix. I confirm that this patch fixes the issue with
> plasma desktop.
Thanks, if you think the fix is OK, can you please give a Reviewed-by?
I will then backport this to the 2.37 branch as well.
Thanks,
Sid
More information about the Libc-alpha
mailing list