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: Tue, 26 Jan 2021 18:02:06 +0300 Message-ID: <6e6b41b5e9e78d4360cb2f90118af2e43ddba548.camel@yandex.ru> References: <83k0rz21dw.fsf@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="7154"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.38.3 Cc: carlos@redhat.com, fweimer@redhat.com, monnier@iro.umontreal.ca, dj@redhat.com, 45200@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jan 26 16:16:02 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 1l4Q4X-0001ii-Pm for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 26 Jan 2021 16:16:01 +0100 Original-Received: from localhost ([::1]:52552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l4Q4W-0001Oy-Q9 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 26 Jan 2021 10:16:00 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55898) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l4Pvq-0006Yk-1b for bug-gnu-emacs@gnu.org; Tue, 26 Jan 2021 10:07:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:59090) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l4Pvp-0004hB-PU for bug-gnu-emacs@gnu.org; Tue, 26 Jan 2021 10:07:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l4Pvp-0000UC-Js for bug-gnu-emacs@gnu.org; Tue, 26 Jan 2021 10:07: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: Tue, 26 Jan 2021 15:07: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.16116736121852 (code B ref 45200); Tue, 26 Jan 2021 15:07:01 +0000 Original-Received: (at 45200) by debbugs.gnu.org; 26 Jan 2021 15:06:52 +0000 Original-Received: from localhost ([127.0.0.1]:42403 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l4Pvg-0000To-1h for submit@debbugs.gnu.org; Tue, 26 Jan 2021 10:06:52 -0500 Original-Received: from forward100p.mail.yandex.net ([77.88.28.100]:42108) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l4Pve-0000Ta-9P for 45200@debbugs.gnu.org; Tue, 26 Jan 2021 10:06:50 -0500 Original-Received: from forward100q.mail.yandex.net (forward100q.mail.yandex.net [IPv6:2a02:6b8:c0e:4b:0:640:4012:bb97]) by forward100p.mail.yandex.net (Yandex) with ESMTP id 1C6FA5982E30; Tue, 26 Jan 2021 18:02:07 +0300 (MSK) Original-Received: from vla1-38e2a3439e30.qloud-c.yandex.net (vla1-38e2a3439e30.qloud-c.yandex.net [IPv6:2a02:6b8:c0d:1e04:0:640:38e2:a343]) by forward100q.mail.yandex.net (Yandex) with ESMTP id 170877080009; Tue, 26 Jan 2021 18:02:07 +0300 (MSK) Original-Received: from vla5-047c0c0d12a6.qloud-c.yandex.net (vla5-047c0c0d12a6.qloud-c.yandex.net [2a02:6b8:c18:3484:0:640:47c:c0d]) by vla1-38e2a3439e30.qloud-c.yandex.net (mxback/Yandex) with ESMTP id QRsqf9GJTi-26HCep6n; Tue, 26 Jan 2021 18:02:07 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1611673327; bh=7T7ov+06wul3Se1WJ6VbYBPxKeEgJev2apwiGeBedVY=; h=In-Reply-To:Cc:To:From:Subject:Message-ID:References:Date; b=ctMbI8JRJanaxkAu7B0XVzDXSd+iOMx0jQJdj+MwnUVA/Hp0Lniq354rYYHEl0Gxa HekwGlM+aAnfxewFopgEHLI3hMGaNWq7fp1FYeJ33kKMW8mS2JWl5FXgaC7jGqaWAx wbBVyfltQot7Y4RCUE0y7cuGc7dMtZtNecuM+Jhw= Authentication-Results: vla1-38e2a3439e30.qloud-c.yandex.net; dkim=pass header.i=@yandex.ru Original-Received: by vla5-047c0c0d12a6.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id 5eSjcoaa5t-26oiQcAq; Tue, 26 Jan 2021 18:02:06 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) In-Reply-To: <83k0rz21dw.fsf@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:198624 Archived-At: On Tue, 2021-01-26 at 16:55 +0200, Eli Zaretskii wrote: > > 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. Sorry, okay. > > 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. Yeah, that's true, there's an existing advice to make GC only run on idle. Which is the reason btw this bugreport eventually came to life ☺