From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dragonfly.birch.relay.mailchannels.net (dragonfly.birch.relay.mailchannels.net [23.83.209.51]) by sourceware.org (Postfix) with ESMTPS id C0DC23858421 for ; Wed, 5 Jul 2023 14:37:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C0DC23858421 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=sourceware.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=sourceware.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id D8B27261C04; Wed, 5 Jul 2023 14:37:44 +0000 (UTC) Received: from pdx1-sub0-mail-a208.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 94D9F261B8D; Wed, 5 Jul 2023 14:37:42 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1688567862; a=rsa-sha256; cv=none; b=seJ63xII/gKMbDOQyaUCoqPaAYLq5rPCGcScxPEK7zNQCdkAID+BhzAcpJiNM/uB6yL8bn 70x39a7+qZySGuFgyct8jbzY3F5B/7gcAk0ZjJk/K3U6VDLvBbZpFuU4O81kEq5y4iMzSF +jgozUSUS0je94aaIRyyy2QVAPMh+U9Py5GR89DBimBkzF+CT29OyZqX7sGeVnV8lBtpjd KB+oTECkxNooDkk/qP6qoRATVpvtCNRWC4SDfN2MgmF6VwmzjPAKNmce8NiGK8B4h0ZviM OufESqlLMj+P6YIF9rF0b8nvAJXALXiY7HlH6C8K5wrgo9y0VQReV4UdT4TDmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1688567862; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rd3dJJ9BYzMmgoDDulbjgQCiD2xN/EI8O59FNDi0be4=; b=dalAY5B0jKVSQu3kNBgnGY1533dg695NwcLyj6FCBSCsQFqZByO4ISBdmqtSMyXi8HIRiF 9Io1gEjUNMUaFkNybxMfNAQ23af01TfpyyswqFjBOMmbo6+JCxTVyVy4+vM4LYE7tsACuu R/lUhSIeRRwSqJKpVttky8feFbndaNfkvltfAQkVHu6d63ycumKVs4td+jKPCSneev+Yxg ZIyvUHEmd+tb0Ec+ykl074odO2gAIWmko/t4SOi9f7wXBZuCAB/jBftxTUbc4QUU/j5bFl lzQcYHWl0a/WEK2jtNqVHE70Jwmfmh3wd2cV82iPYi7TEVZ2I/qXaAaLb5gQOg== ARC-Authentication-Results: i=1; rspamd-9fcc56855-jzllm; auth=pass smtp.auth=dreamhost smtp.mailfrom=siddhesh@sourceware.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org X-MC-Relay: Neutral X-MC-Copy: stored-urls X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Daffy-Tank: 1535edc96a402a93_1688567864040_2811022465 X-MC-Loop-Signature: 1688567864040:1787465269 X-MC-Ingress-Time: 1688567864040 Received: from pdx1-sub0-mail-a208.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.127.59.48 (trex/6.9.1); Wed, 05 Jul 2023 14:37:44 +0000 Received: from [192.168.54.119] (unknown [72.139.195.115]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a208.dreamhost.com (Postfix) with ESMTPSA id 4Qx2Ls6qPYzdp; Wed, 5 Jul 2023 07:37:41 -0700 (PDT) Message-ID: Date: Wed, 5 Jul 2023 10:37:17 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH] realloc: Limit chunk reuse to only growing requests [BZ #30579] Content-Language: en-US To: libc-alpha@sourceware.org, Nicolas Dusart References: <20230704182402.1040962-1-siddhesh@sourceware.org> From: Siddhesh Poyarekar In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1163.6 required=5.0 tests=BAYES_00,KAM_DMARC_NONE,KAM_DMARC_STATUS,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_SOFTFAIL,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 >> Reported-by: Nicolas Dusart >> Reported-by: Aurelien Jarno >> --- >> >> 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