From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Konstantin Kharlamov Newsgroups: gmane.emacs.bugs Subject: bug#45200: [PATCH] Force Glibc to free the memory freed Date: Wed, 03 Feb 2021 09:04:21 +0300 Message-ID: <8a91fc16f93298bca1281b43d6821ae3621376dc.camel@yandex.ru> References: <83k0rz21dw.fsf@gnu.org> <331805c74fc5d3d412dd2065030b11fa3343710d.camel@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39081"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.38.3 Cc: carlos@redhat.com, fweimer@redhat.com, 45200@debbugs.gnu.org, dj@redhat.com To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 03 07:05:27 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l7BI7-000A4P-L5 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 03 Feb 2021 07:05:27 +0100 Original-Received: from localhost ([::1]:54446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7BI6-0000Fd-J2 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 03 Feb 2021 01:05:26 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47486) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7BHi-0000FI-4V for bug-gnu-emacs@gnu.org; Wed, 03 Feb 2021 01:05:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53261) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l7BHh-000624-Sw for bug-gnu-emacs@gnu.org; Wed, 03 Feb 2021 01:05:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l7BHh-0007xY-MG for bug-gnu-emacs@gnu.org; Wed, 03 Feb 2021 01:05:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Konstantin Kharlamov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 03 Feb 2021 06:05:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45200 X-GNU-PR-Package: emacs Original-Received: via spool by 45200-submit@debbugs.gnu.org id=B45200.161233227430555 (code B ref 45200); Wed, 03 Feb 2021 06:05:01 +0000 Original-Received: (at 45200) by debbugs.gnu.org; 3 Feb 2021 06:04:34 +0000 Original-Received: from localhost ([127.0.0.1]:36574 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7BHF-0007wk-Pf for submit@debbugs.gnu.org; Wed, 03 Feb 2021 01:04:34 -0500 Original-Received: from forward103p.mail.yandex.net ([77.88.28.106]:49812) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7BHB-0007wT-8f for 45200@debbugs.gnu.org; Wed, 03 Feb 2021 01:04:32 -0500 Original-Received: from iva5-d37fe543de32.qloud-c.yandex.net (iva5-d37fe543de32.qloud-c.yandex.net [IPv6:2a02:6b8:c0c:6a6:0:640:d37f:e543]) by forward103p.mail.yandex.net (Yandex) with ESMTP id 728BA18C0160; Wed, 3 Feb 2021 09:04:22 +0300 (MSK) Original-Received: from iva8-174eb672ffa9.qloud-c.yandex.net (iva8-174eb672ffa9.qloud-c.yandex.net [2a02:6b8:c0c:b995:0:640:174e:b672]) by iva5-d37fe543de32.qloud-c.yandex.net (mxback/Yandex) with ESMTP id dEruPcMapr-4LIO8n5g; Wed, 03 Feb 2021 09:04:22 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1612332262; bh=3uIUWppCNTatPRpTltII+niAeTdkH3p+YUqqd5GRy5s=; h=In-Reply-To:Cc:To:From:Subject:Message-ID:References:Date; b=Ts94VpL9wh9aFMBElmq5qnLtDo3/35WXSYGPG35vxgHepBSsanyGiugctoI0cqpKV qo1cpWVVPwuWXMI5meTboqUj0LfC6YAeiypeYciwbqKUByewNyaIZmrFAHNJhUZnKQ OPBHJIoPu3rBA7pkoAgRd02FZRcTORvjmgmycmXM= Authentication-Results: iva5-d37fe543de32.qloud-c.yandex.net; dkim=pass header.i=@yandex.ru Original-Received: by iva8-174eb672ffa9.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id 23k5Lf1a3K-4LoS21np; Wed, 03 Feb 2021 09:04:21 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:199177 Archived-At: On Tue, 2021-02-02 at 23:50 -0500, Stefan Monnier wrote: > > >     with malloc_trim: > > >         (8.920371394 232 2.106283245) > > >         (9.038083601 231 2.060810826) > > >         (9.140798641 231 2.0594013240000004) > > > > > >     without malloc_trim: > > >         (8.987097209 232 2.070143482) > > >         (8.700478084 231 1.7745506179999997) > > >         (8.781121056 231 1.7870093610000004) > > > > > > The difference is just 3-4% (8.7 / 9 ≈ 0.9666666667). It looks to me > > > insignificant enough to not show up anywhere during interactive work > > > with Emacs. > > > > It's indeed not too costly, but what about the upside? > > BTW, maybe a better way forward than trying to convince us that it's > a good default (which could be hard if the upside is a reduction of the > memory use by a few percent: for many people it might be less > relevant/noticeable than the corresponding few percents lost in speed) > is to provide a patch that adds a new *ELisp* function that calls > `malloc_trim`, which you can then add to `post-gc-hook` in your init > file when your usage pattern makes it useful. Upside indeed is the memory reduction. Well, I didn't send the patches for my only benefit, but for benefit of others people. The new ELisp function is something that not too many people would benefit from, and I mean, including those who disable GC. That is because it would be an opt-in feature, which you need to know about to enable it, and not many will ever find out about it. For my-only benefit I could just continue building Emacs with my patch applied locally, as I do now.