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 10:15:19 +0300 Message-ID: References: <83k0rz21dw.fsf@gnu.org> <331805c74fc5d3d412dd2065030b11fa3343710d.camel@yandex.ru> <8a91fc16f93298bca1281b43d6821ae3621376dc.camel@yandex.ru> <67DDB032-C3DF-4748-A3EF-EEC374EDB251@gnu.org> 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="19155"; 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: Eli Zaretskii , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 03 08:16:36 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 1l7COy-0004s1-RA for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 03 Feb 2021 08:16:36 +0100 Original-Received: from localhost ([::1]:45538 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7COx-0005UL-QN for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 03 Feb 2021 02:16:35 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57730) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7COS-0005Tw-Pg for bug-gnu-emacs@gnu.org; Wed, 03 Feb 2021 02:16:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53301) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l7COP-0004Ov-Q0 for bug-gnu-emacs@gnu.org; Wed, 03 Feb 2021 02:16:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l7COP-0001Sk-Kn for bug-gnu-emacs@gnu.org; Wed, 03 Feb 2021 02:16: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 07:16: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.16123365315574 (code B ref 45200); Wed, 03 Feb 2021 07:16:01 +0000 Original-Received: (at 45200) by debbugs.gnu.org; 3 Feb 2021 07:15:31 +0000 Original-Received: from localhost ([127.0.0.1]:36614 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7CNu-0001Rq-JM for submit@debbugs.gnu.org; Wed, 03 Feb 2021 02:15:30 -0500 Original-Received: from forward100j.mail.yandex.net ([5.45.198.240]:57726) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7CNq-0001RX-Mj for 45200@debbugs.gnu.org; Wed, 03 Feb 2021 02:15:28 -0500 Original-Received: from sas1-46fc755e9ad1.qloud-c.yandex.net (sas1-46fc755e9ad1.qloud-c.yandex.net [IPv6:2a02:6b8:c08:168c:0:640:46fc:755e]) by forward100j.mail.yandex.net (Yandex) with ESMTP id 97AB950E3DB2; Wed, 3 Feb 2021 10:15:20 +0300 (MSK) Original-Received: from sas1-37da021029ee.qloud-c.yandex.net (sas1-37da021029ee.qloud-c.yandex.net [2a02:6b8:c08:1612:0:640:37da:210]) by sas1-46fc755e9ad1.qloud-c.yandex.net (mxback/Yandex) with ESMTP id 2UQ3eyOtp1-FJHaR8mv; Wed, 03 Feb 2021 10:15:20 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1612336520; bh=xxpteFaYoJ1GJKNf8TzYXqW77FqeCJ1VsCEyYZ4Bxls=; h=In-Reply-To:Cc:To:From:Subject:Message-ID:References:Date; b=mj0JerLQSj6NJuS6WeNmgblyDjCDGWEr3nFLxTcdMiYcshSBXpVsfBS025wUXPCBn nYb8n1BGc56c3fzRY1CIMshQwm4zJ4a5Sq9l8rCZVQSzdVNBXcNl+dY3JbcytdXSGS aKBs8g0pSh1eKXKRaxOrpOmGphpsXzYwNIFTKeO0= Authentication-Results: sas1-46fc755e9ad1.qloud-c.yandex.net; dkim=pass header.i=@yandex.ru Original-Received: by sas1-37da021029ee.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id a6ThhMwydP-FJnafNgq; Wed, 03 Feb 2021 10:15:19 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) In-Reply-To: <67DDB032-C3DF-4748-A3EF-EEC374EDB251@gnu.org> 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:199179 Archived-At: On Wed, 2021-02-03 at 09:07 +0200, Eli Zaretskii wrote: > On February 3, 2021 8:04:21 AM GMT+02:00, Konstantin Kharlamov > wrote: > > 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. > > How much memory reduction?  Can you show the numbers? Sure. When I run the testcase for the problem that I posted in 3rd email on this thread¹, vanilla Emacs takes up 260.3M of PSS and never goes below, not even upon re-running (garbage-collect) manually. The patched Emacs on the other hand has 64.3M of PSS right after the testcase finishes. 1: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=45200#11