diff options
| author | Lars Ingebrigtsen | 2022-06-21 15:04:27 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2022-06-21 15:04:38 +0200 |
| commit | 73a384a98698ae1ef655c41a2b76a31b3f2c80fc (patch) | |
| tree | 4268964b57e350f8f8643bd8209d08e39db928fb | |
| parent | 0939465300f7c80f110c8596c0388f555619ea62 (diff) | |
| download | emacs-73a384a98698ae1ef655c41a2b76a31b3f2c80fc.tar.gz emacs-73a384a98698ae1ef655c41a2b76a31b3f2c80fc.zip | |
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.
| -rw-r--r-- | doc/lispref/os.texi | 6 | ||||
| -rw-r--r-- | etc/NEWS | 8 | ||||
| -rw-r--r-- | src/emacs.c | 6 |
3 files changed, 20 insertions, 0 deletions
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index bc5374f10f2..262ef8bbfde 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 | |||
| 2738 | @code{coding-system-for-write} to a coding system of you choice | 2738 | @code{coding-system-for-write} to a coding system of you choice |
| 2739 | (@pxref{Explicit Encoding}). | 2739 | (@pxref{Explicit Encoding}). |
| 2740 | 2740 | ||
| 2741 | In batch mode, Emacs will adjust the @code{gc-cons-threshold} variable | ||
| 2742 | up from a default of @samp{0.1} to @samp{1.0}. Batch jobs that are | ||
| 2743 | supposed to run for a long time should adjust the limit back down | ||
| 2744 | again, because this means that less garbage collection will be | ||
| 2745 | performed by default (and more memory consumed). | ||
| 2746 | |||
| 2741 | @defvar noninteractive | 2747 | @defvar noninteractive |
| 2742 | This variable is non-@code{nil} when Emacs is running in batch mode. | 2748 | This variable is non-@code{nil} when Emacs is running in batch mode. |
| 2743 | @end defvar | 2749 | @end defvar |
| @@ -117,6 +117,14 @@ Emacs Sessions" node in the Emacs manual for more details. | |||
| 117 | * Startup Changes in Emacs 29.1 | 117 | * Startup Changes in Emacs 29.1 |
| 118 | 118 | ||
| 119 | +++ | 119 | +++ |
| 120 | ** -batch and -script now adjusts the garbage collection levels. | ||
| 121 | These switches now set 'gc-cons-percentage' to 1.0 (up from the | ||
| 122 | default of 0.1). This means that batch processes will typically use | ||
| 123 | more memory than before, but use less time doing garbage collection. | ||
| 124 | Batch jobs that are supposed to run for a long time should adjust the | ||
| 125 | limit back down again. | ||
| 126 | |||
| 127 | +++ | ||
| 120 | ** Emacs can now be used more easily in an executable script. | 128 | ** Emacs can now be used more easily in an executable script. |
| 121 | If you start an executable script with | 129 | If you start an executable script with |
| 122 | 130 | ||
diff --git a/src/emacs.c b/src/emacs.c index 5098acd7225..c602157da16 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 | |||
| 1944 | if (!initialized) | 1944 | if (!initialized) |
| 1945 | syms_of_comp (); | 1945 | syms_of_comp (); |
| 1946 | 1946 | ||
| 1947 | /* Do less garbage collection in batch mode (since these tend to be | ||
| 1948 | more short-lived, and the memory is returned to the OS on exit | ||
| 1949 | anyway). */ | ||
| 1950 | if (noninteractive) | ||
| 1951 | Vgc_cons_percentage = make_float (1.0); | ||
| 1952 | |||
| 1947 | no_loadup | 1953 | no_loadup |
| 1948 | = argmatch (argv, argc, "-nl", "--no-loadup", 6, NULL, &skip_args); | 1954 | = argmatch (argv, argc, "-nl", "--no-loadup", 6, NULL, &skip_args); |
| 1949 | 1955 | ||