unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: [Emacs-diffs] master 5018b66 4/6: Inhibit GC after inhibit_garbage_collection
Date: Sun, 21 Jul 2019 11:42:39 -0700	[thread overview]
Message-ID: <f202703c-b823-bd5d-68dd-cc6a437e782d@cs.ucla.edu> (raw)
In-Reply-To: <jwvv9vvtrsm.fsf-monnier+emacs@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 202 bytes --]

Stefan Monnier wrote:
> Maybe we could circumvent this by temporarily bumping gc_relative_threshold?

Sure, I installed the attached. It bumps consing_until_gc which is how the 
thresholding works now.

[-- Attachment #2: 0001-Speed-up-maybe_gc-when-GC-is-inhibited.patch --]
[-- Type: text/x-patch, Size: 1580 bytes --]

From d02c2f7f6507105605ed0596a7e26acd5b3b8122 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sun, 21 Jul 2019 11:20:07 -0700
Subject: [PATCH] Speed up maybe_gc when GC is inhibited

* src/alloc.c (allow_garbage_collection)
(inhibit_garbage_collection): Temporarily bump
consing_until_gc, to improve performance of maybe_gc while
garbage collection is inhibited.  Suggested by Stefan Monnier in:
https://lists.gnu.org/r/emacs-devel/2019-07/msg00511.html
---
 src/alloc.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/alloc.c b/src/alloc.c
index b7ba886482..50015808e5 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -5501,11 +5501,14 @@ staticpro (Lisp_Object const *varaddress)
 			  Protection from GC
  ***********************************************************************/
 
-/* Temporarily prevent garbage collection.  */
+/* Temporarily prevent garbage collection.  Temporarily bump
+   consing_until_gc to speed up maybe_gc when GC is inhibited.  */
 
 static void
-allow_garbage_collection (void)
+allow_garbage_collection (void *ptr)
 {
+  object_ct *p = ptr;
+  consing_until_gc = *p;
   garbage_collection_inhibited--;
 }
 
@@ -5513,9 +5516,10 @@ ptrdiff_t
 inhibit_garbage_collection (void)
 {
   ptrdiff_t count = SPECPDL_INDEX ();
-
-  record_unwind_protect_void (allow_garbage_collection);
+  object_ct consing = consing_until_gc;
+  record_unwind_protect_ptr (allow_garbage_collection, &consing);
   garbage_collection_inhibited++;
+  consing_until_gc = OBJECT_CT_MAX;
   return count;
 }
 
-- 
2.17.1


      reply	other threads:[~2019-07-21 18:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190721031351.22349.23406@vcs0.savannah.gnu.org>
     [not found] ` <20190721031354.BA68420BE2@vcs0.savannah.gnu.org>
2019-07-21  9:57   ` [Emacs-diffs] master 515afc9 6/6: Fix crash if user test munges hash table Pip Cet
2019-07-21 18:39     ` Paul Eggert
     [not found] ` <20190721031353.DBCBC20BE2@vcs0.savannah.gnu.org>
2019-07-21 14:01   ` [Emacs-diffs] master 5018b66 4/6: Inhibit GC after inhibit_garbage_collection Stefan Monnier
2019-07-21 18:42     ` Paul Eggert [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f202703c-b823-bd5d-68dd-cc6a437e782d@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).