emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 73a384a986: Increase gc-cons-percentage in -batch Emacs


From: Lars Ingebrigtsen
Subject: master 73a384a986: Increase gc-cons-percentage in -batch Emacs
Date: Tue, 21 Jun 2022 09:04:44 -0400 (EDT)

branch: master
commit 73a384a98698ae1ef655c41a2b76a31b3f2c80fc
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Increase gc-cons-percentage in -batch Emacs
    
    * doc/lispref/os.texi (Batch Mode): Document it.
    
    * src/emacs.c (main): Use a gc-cons-percentage of 1.0 in
    noninteractive Emacsen.
---
 doc/lispref/os.texi | 6 ++++++
 etc/NEWS            | 8 ++++++++
 src/emacs.c         | 6 ++++++
 3 files changed, 20 insertions(+)

diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
index bc5374f10f..262ef8bbfd 100644
--- a/doc/lispref/os.texi
+++ b/doc/lispref/os.texi
@@ -2738,6 +2738,12 @@ if it is non-@code{nil}; this can be overridden by 
binding
 @code{coding-system-for-write} to a coding system of you choice
 (@pxref{Explicit Encoding}).
 
+In batch mode, Emacs will adjust the @code{gc-cons-threshold} variable
+up from a default of @samp{0.1} to @samp{1.0}.  Batch jobs that are
+supposed to run for a long time should adjust the limit back down
+again, because this means that less garbage collection will be
+performed by default (and more memory consumed).
+
 @defvar noninteractive
 This variable is non-@code{nil} when Emacs is running in batch mode.
 @end defvar
diff --git a/etc/NEWS b/etc/NEWS
index fdc2e99ca4..cb59d166f7 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -116,6 +116,14 @@ Emacs Sessions" node in the Emacs manual for more details.
 
 * Startup Changes in Emacs 29.1
 
++++
+** -batch and -script now adjusts the garbage collection levels.
+These switches now set 'gc-cons-percentage' to 1.0 (up from the
+default of 0.1).  This means that batch processes will typically use
+more memory than before, but use less time doing garbage collection.
+Batch jobs that are supposed to run for a long time should adjust the
+limit back down again.
+
 +++
 ** Emacs can now be used more easily in an executable script.
 If you start an executable script with
diff --git a/src/emacs.c b/src/emacs.c
index 5098acd722..c602157da1 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -1944,6 +1944,12 @@ Using an Emacs configured with --with-x-toolkit=lucid 
does not have this problem
   if (!initialized)
     syms_of_comp ();
 
+  /* Do less garbage collection in batch mode (since these tend to be
+     more short-lived, and the memory is returned to the OS on exit
+     anyway).  */
+  if (noninteractive)
+    Vgc_cons_percentage = make_float (1.0);
+
   no_loadup
     = argmatch (argv, argc, "-nl", "--no-loadup", 6, NULL, &skip_args);
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]