From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from hall.aurel32.net (hall.aurel32.net [IPv6:2001:bc8:30d7:100::1]) by sourceware.org (Postfix) with ESMTPS id 9314A3858D33; Thu, 6 Jul 2023 10:33:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9314A3858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=aurel32.net Authentication-Results: sourceware.org; spf=none smtp.mailfrom=aurel32.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=aurel32.net ; s=202004.hall; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Content-Transfer-Encoding:From:Reply-To: Subject:Content-ID:Content-Description:X-Debbugs-Cc; bh=73lBgARIHIOP3nR+HHuIng/BCx4q02Nu68dudlt9pTY=; b=i+JJYFgV4J0i4b88Jdltk+g6RD eAMdLisM9NfHH1bxZo2c/TtC2Q50eC2QjYporZ+k8yJpWSKZnPaa1ox7B5mWq/bntFiFLsJYiWbxz CjAkj6nREJ8BvTDxr/dPr4w6HhLXB5ypjJOs8LdWTl822VWRnLQH4rQzg8nmPmZPENzv/eDvIUbm0 luNOg6VL6LO+EX1ThnBUw8REmPZawpQ2xMGNO3bW8kOzi/FMdi/HFqdNLMKBqrOeq4gui65ot/1Ym 6thdxv9+TwXYY/2FZEDiEYcx7lRhCRVW+cSwscsxrYVmdYIlxNZgyXM7qY5oGjbO+Kdag5mdhcjUP 8GvOiBpA==; Received: from [2a01:e34:ec5d:a741:8a4c:7c4e:dc4c:1787] (helo=ohm.rr44.fr) by hall.aurel32.net with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qHMIn-001Pk9-1E; Thu, 06 Jul 2023 12:33:33 +0200 Received: from aurel32 by ohm.rr44.fr with local (Exim 4.96) (envelope-from ) id 1qH7GZ-001Bzo-3A; Wed, 05 Jul 2023 20:30:15 +0200 Date: Wed, 5 Jul 2023 20:30:15 +0200 From: Aurelien Jarno To: Siddhesh Poyarekar Cc: libc-alpha@sourceware.org, Nicolas Dusart Subject: Re: [PATCH] realloc: Limit chunk reuse to only growing requests [BZ #30579] Message-ID: Mail-Followup-To: Siddhesh Poyarekar , libc-alpha@sourceware.org, Nicolas Dusart References: <20230704182402.1040962-1-siddhesh@sourceware.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.2.9 (2022-11-12) X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00,DATE_IN_PAST_12_24,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_NONE,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 10:37, Siddhesh Poyarekar via Libc-alpha wrote: > 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. Yep, of course. Reviewed-by: Aurelien Jarno Tested-by: Aurelien Jarno -- Aurelien Jarno GPG: 4096R/1DDD8C9B aurelien@aurel32.net http://aurel32.net