unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* GC mark stack
@ 2022-06-26 15:31 Lynn Winebarger
  2022-06-26 15:50 ` Lynn Winebarger
  2022-08-15 14:01 ` Stefan Monnier
  0 siblings, 2 replies; 9+ messages in thread
From: Lynn Winebarger @ 2022-06-26 15:31 UTC (permalink / raw)
  To: emacs-devel

I was reviewing alloc.c in the 28.1 source, and noted that it uses a
semi-naive computation of the transitive closure of the graph of live
data structures (weak hash tables is where I see it).
Since the fix to https://debbugs.gnu.org/cgi/bugreport.cgi?bug=54698
(commit 7a8798de95a57c8ff85f070075e0a0176b458578) moved to using an
explicit stack, I was curious if you'd considered using a variant of
Tarjan's SCC algorithm, such as the one described in
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.40.9019&rep=rep1&type=pdf
,
to guarantee that each edge is traversed at most once.  The algorithm
described never removes traversed objects from its stack (so it can
tell when an object has already been traversed, even if the current
link into it is not part of its SCC).
The algorithm would only need to account for objects like weak hash
tables, so a direct implementation would only leave those on the
stack.  An alternative would be to create an additional field in the
objects (like weak hash table) recording the order in which they were
traversed, which also makes the algorithm more efficient since there's
no stack search involved when determining the SCC representative of
particular node - it's just a matter of comparing their stack
ordering.
Of course, I don't have any idea how much time is spent on this type
of recursion for weak references.  The SCC-based algorithms can make a
significant performance improvement compared to semi-naive calculation
of transitive closure for general relational queries.  It might not be
so useful when you don't require an explicit enumeration of the set of
answers.

Lynn



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-08-16  9:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-26 15:31 GC mark stack Lynn Winebarger
2022-06-26 15:50 ` Lynn Winebarger
2022-08-15 14:01 ` Stefan Monnier
2022-08-15 14:51   ` Lynn Winebarger
2022-08-15 16:28     ` Stefan Monnier
2022-08-15 17:52       ` Lynn Winebarger
2022-08-15 18:17         ` Stefan Monnier
2022-08-16  1:53           ` Lynn Winebarger
2022-08-16  9:50             ` Lynn Winebarger

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).