[Top][All Lists]

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

master 0fc4989: Tweak GC performance if !USE_LSB_TAG

From: Paul Eggert
Subject: master 0fc4989: Tweak GC performance if !USE_LSB_TAG
Date: Tue, 26 May 2020 18:48:35 -0400 (EDT)

branch: master
commit 0fc4989f34bdaf1bc443d05ece886ea91e7bc9cc
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Tweak GC performance if !USE_LSB_TAG
    Performance issue reported by Eli Zaretskii (Bug#41321#149).
    * src/alloc.c (GC_OBJECT_ALIGNMENT_MINIMUM): New constant.
    (maybe_lisp_pointer): Use it instead of GCALIGNMENT.
 src/alloc.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/alloc.c b/src/alloc.c
index f860939..e241b99 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -4687,16 +4687,33 @@ mark_maybe_objects (Lisp_Object const *array, ptrdiff_t 
     mark_maybe_object (*array);
+/* A lower bound on the alignment of Lisp objects that need marking.
+   Although 1 is safe, higher values speed up mark_maybe_pointer.
+   If USE_LSB_TAG, this value is typically GCALIGNMENT; otherwise,
+   it's determined by the natural alignment of Lisp structs.
+   All vectorlike objects have alignment at least that of union
+   vectorlike_header and it's unlikely they all have alignment greater,
+   so use the union as a safe and likely-accurate standin for
+   vectorlike objects.  */
+         = max (GCALIGNMENT,
+               min (alignof (union vectorlike_header),
+                    min (min (alignof (struct Lisp_Cons),
+                              alignof (struct Lisp_Float)),
+                         min (alignof (struct Lisp_String),
+                              alignof (struct Lisp_Symbol))))) };
 /* Return true if P might point to Lisp data that can be garbage
    collected, and false otherwise (i.e., false if it is easy to see
    that P cannot point to Lisp data that can be garbage collected).
    Symbols are implemented via offsets not pointers, but the offsets
-   are also multiples of GCALIGNMENT.  */
+   are also multiples of GC_OBJECT_ALIGNMENT_MINIMUM.  */
 static bool
 maybe_lisp_pointer (void *p)
-  return (uintptr_t) p % GCALIGNMENT == 0;
+  return (uintptr_t) p % GC_OBJECT_ALIGNMENT_MINIMUM == 0;
 /* If P points to Lisp data, mark that as live if it isn't already

reply via email to

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