From: Mattias EngdegÄrd Date: Tue, 17 Sep 2024 11:07:01 +0000 (+0200) Subject: Re-enable GC mark trace buffer by default X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=55b8363b5c374a5bba0384067acb13abbe99a559;p=emacs.git Re-enable GC mark trace buffer by default Enable GC_REMEMBER_LAST_MARKED by default (it was disabled in Emacs 29) to make it easier to debug difficult-to-reproduce GC problems encountered by users. This increases GC costs by about 5 %, which can be avoided by turning the mark trace buffer back off using the new --disable-gc-mark-trace option. See discussion at https://lists.gnu.org/archive/html/emacs-devel/2024-09/msg00240.html * configure.ac (--disable-gc-mark-trace): New config option. * etc/NEWS: Mention it. * src/alloc.c: Enable it by default and avoid a compiler warning. (cherry picked from commit 4c6f45fa8eef1a15d5790c1f3d3e608b548015db) --- diff --git a/configure.ac b/configure.ac index b89709b46f8..990434b45ff 100644 --- a/configure.ac +++ b/configure.ac @@ -782,6 +782,17 @@ AS_IF([test "$with_android" = no || test -n "$XCONFIGURE"],[ [android_enable_checking=yes export android_enable_checking])]) +AC_ARG_ENABLE([gc-mark-trace], + [AS_HELP_STRING([--disable-gc-mark-trace], + [disable the mark trace buffer used for debugging the Emacs + garbage collector])], + [ac_enable_gc_mark_trace="${enableval}"], + [ac_enable_gc_mark_trace=yes]) +if test "x$ac_enable_gc_mark_trace" = xyes ; then + AC_DEFINE([GC_REMEMBER_LAST_MARKED], [1], + [Define to 1 to enable GC mark trace buffer.]) +fi + dnl The name of this option is unfortunate. It predates, and has no dnl relation to, the "sampling-based elisp profiler" added in 24.3. dnl Actually, it stops it working. diff --git a/etc/NEWS b/etc/NEWS index 875a614915d..232322f8779 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -31,6 +31,13 @@ host system supports SSE2) or '-fno-tree-sra' (if not). These GCC options work around GCC bug 58416, which can cause Emacs to behave incorrectly in rare cases. +--- +** New configuration option '--disable-gc-mark-trace'. +This disables the GC mark trace buffer for about 5 % better garbage +collection performance. Doing so may make it more difficult for Emacs +developers to help finding GC-related bugs that you run into, which is +why it the mark trace buffer is enabled by default. + * Startup Changes in Emacs 31.1 diff --git a/src/alloc.c b/src/alloc.c index 066ec9fefe5..4fab0d54248 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -6860,11 +6860,10 @@ mark_glyph_matrix (struct glyph_matrix *matrix) } } -/* Whether to remember a few of the last marked values for debugging. */ -#define GC_REMEMBER_LAST_MARKED 0 - #if GC_REMEMBER_LAST_MARKED +/* Remember a few of the last marked values for debugging purposes. */ enum { LAST_MARKED_SIZE = 1 << 9 }; /* Must be a power of 2. */ +extern Lisp_Object last_marked[LAST_MARKED_SIZE]; Lisp_Object last_marked[LAST_MARKED_SIZE] EXTERNALLY_VISIBLE; static int last_marked_index; #endif