From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#45200: [PATCH] Force Glibc to free the memory freed Date: Tue, 26 Jan 2021 16:55:55 +0200 Message-ID: <83k0rz21dw.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6082"; mail-complaints-to="usenet@ciao.gmane.io" Cc: carlos@redhat.com, fweimer@redhat.com, monnier@iro.umontreal.ca, dj@redhat.com, 45200@debbugs.gnu.org To: Konstantin Kharlamov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jan 26 16:15:51 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 1l4Q4M-0001Ov-Mh for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 26 Jan 2021 16:15:50 +0100 Original-Received: from localhost ([::1]:51686 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l4Q4L-00013L-Mm for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 26 Jan 2021 10:15:49 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l4PlC-0007mK-1w for bug-gnu-emacs@gnu.org; Tue, 26 Jan 2021 09:56:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:59081) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l4PlB-0000jk-Pt for bug-gnu-emacs@gnu.org; Tue, 26 Jan 2021 09:56:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l4PlB-0000ED-Nm for bug-gnu-emacs@gnu.org; Tue, 26 Jan 2021 09:56:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 26 Jan 2021 14:56: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.1611672961874 (code B ref 45200); Tue, 26 Jan 2021 14:56:01 +0000 Original-Received: (at 45200) by debbugs.gnu.org; 26 Jan 2021 14:56:01 +0000 Original-Received: from localhost ([127.0.0.1]:42394 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l4PlA-0000Dz-UV for submit@debbugs.gnu.org; Tue, 26 Jan 2021 09:56:01 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:35324) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l4Pl9-0000Dt-Rl for 45200@debbugs.gnu.org; Tue, 26 Jan 2021 09:56:00 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:52055) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l4Pl4-0000fX-0X; Tue, 26 Jan 2021 09:55:54 -0500 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2186 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1l4Pku-0002hT-GW; Tue, 26 Jan 2021 09:55:46 -0500 In-Reply-To: (message from Konstantin Kharlamov on Tue, 26 Jan 2021 01:28:01 +0300) 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:198623 Archived-At: > From: Konstantin Kharlamov > Cc: 45200@debbugs.gnu.org, monnier@iro.umontreal.ca > Date: Tue, 26 Jan 2021 01:28:01 +0300 > > On Mon, 2021-01-25 at 17:17 -0500, DJ Delorie wrote: > > Eli Zaretskii writes: > > > Thanks, but is it really a good idea to call malloc_trim each time we > > > free some chunk of memory? > > > > malloc_trim() is very expensive relative to free(), partly because of > > what it needs to do, and partly because it flushes the fastbins cache. > > If you call it every, say, 1000 iterations of free, that might suffice. > > Or perhaps after each GC run. > > (un-ccing Glibc maintainers as this question is Emacs-specific) Please don't, I invited them to these discussions because they can help us make the right decisions. > After a GC run, would that be at the end of `garbage_collect` function as Stefan > mentioned? That'd be easy to implement, but I'm not yet sure it's the best alternative. In particular, I'd like to have some idea regarding how much time such a call could take. In some usage patterns Emacs calls GC very frequently, which slows down command execution and makes Emacs less responsive. So much so that some people raise the GC threshold too high trying to avoid this slowdown, and raising the threshold too much is generally not a good idea. I don't want us to slow GC down even more so that more people would shoot themselves in the foot by raising the threshold.