From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#65700: time when gcs-done is updated needs to be clarified Date: Thu, 07 Sep 2023 10:58:46 -0400 Message-ID: References: <83pm2uz6nv.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35212"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , "65700@debbugs.gnu.org" <65700@debbugs.gnu.org> To: Shynur Xie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 07 16:59:28 2023 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 1qeGTf-0008yA-UR for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 07 Sep 2023 16:59:28 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeGTY-0007C8-Qo; Thu, 07 Sep 2023 10:59:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeGTF-0007Ba-MO for bug-gnu-emacs@gnu.org; Thu, 07 Sep 2023 10:59:04 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeGTE-0005SA-8g for bug-gnu-emacs@gnu.org; Thu, 07 Sep 2023 10:59:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qeGTF-0001Sw-TQ for bug-gnu-emacs@gnu.org; Thu, 07 Sep 2023 10:59:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 07 Sep 2023 14:59:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65700 X-GNU-PR-Package: emacs Original-Received: via spool by 65700-submit@debbugs.gnu.org id=B65700.16940987385621 (code B ref 65700); Thu, 07 Sep 2023 14:59:01 +0000 Original-Received: (at 65700) by debbugs.gnu.org; 7 Sep 2023 14:58:58 +0000 Original-Received: from localhost ([127.0.0.1]:40892 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qeGTB-0001SZ-RC for submit@debbugs.gnu.org; Thu, 07 Sep 2023 10:58:58 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:45871) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qeGTA-0001SH-10 for 65700@debbugs.gnu.org; Thu, 07 Sep 2023 10:58:57 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id B5404807A7; Thu, 7 Sep 2023 10:58:48 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1694098727; bh=RfqXyjGDTGfljOFjWvIMq+F9tGTIWi7kWetL3WhBybc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Nnz5723Sl5NC7CD5J8op/dghziW1yby2G20DXpVK6GB8oIZWLJIiVTJuLpt58lCQ0 Ho4QzX6y8+4jCY+vkfU+hhrZ8Hes/mYwsrqGad69dBgTbJF2e7v8SxSoYBRNGk8FGi R+HhJa134cEnvi079TpapZlrAiEdyimFVTaKqaF1q9ZhjKWfOKa5nC6ag/iOXr7Ps5 +qllGHfth4kD6a/G91TozB/rNYhNZknuAOEfE/gpz+fjvfObxeeB4WQ4xSNxAqD9yl t2hzLGeqLhdd7yL1sB8hC7Kg72kOVFY6sw732vbxkEtK4rJzaAByby4AGhbz8fMzRV ScDamDK8LB1WQ== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 48ECB803E0; Thu, 7 Sep 2023 10:58:47 -0400 (EDT) Original-Received: from pastel (69-165-136-223.dsl.teksavvy.com [69.165.136.223]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 1E015120263; Thu, 7 Sep 2023 10:58:47 -0400 (EDT) In-Reply-To: (Shynur Xie's message of "Thu, 7 Sep 2023 14:35:32 +0000") 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:269673 Archived-At: >> I'd be curious to know how it affects your code. > My Emacs displays its runtime information like this: > > Since it's mainly related to GC, I have it updated after each GC. Hmm... that doesn't really explain in which way this affects your code. If you only ever run that from `post-gc-hook` the only difference is that `gcs-done` will be always smaller by 1 and since it doesn't start at 0 anyway it's not really relevant: it will still increase by 1 every time `post-gc-hook` is run. FWIW, I tend to agree that it would be more useful to run `post-gc-hook` after those values have been updated. So that `post-gc-hook` can know the exact duration of the GC that we just finished, rather than the one before that. Any objection to the patch below? Stefan diff --git a/src/alloc.c b/src/alloc.c index c77bdc6372d..cee43783387 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -6595,13 +6595,6 @@ garbage_collect (void) image_prune_animation_caches (false); #endif - if (!NILP (Vpost_gc_hook)) - { - specpdl_ref gc_count = inhibit_garbage_collection (); - safe_run_hooks (Qpost_gc_hook); - unbind_to (gc_count, Qnil); - } - /* Accumulate statistics. */ if (FLOATP (Vgc_elapsed)) { @@ -6620,6 +6613,13 @@ garbage_collect (void) if (tot_after < tot_before) malloc_probe (min (tot_before - tot_after, SIZE_MAX)); } + + if (!NILP (Vpost_gc_hook)) + { + specpdl_ref gc_count = inhibit_garbage_collection (); + safe_run_hooks (Qpost_gc_hook); + unbind_to (gc_count, Qnil); + } } DEFUN ("garbage-collect", Fgarbage_collect, Sgarbage_collect, 0, 0, "",