[Top][All Lists]

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

Re: GC mark stack

From: Stefan Monnier
Subject: Re: GC mark stack
Date: Mon, 15 Aug 2022 12:28:17 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

>> Are you talking about the code in `mark_and_sweep_weak_table_contents`?
>> Maybe the `do .. while` loop?
> That is exactly it.  Some of my characterization of the mark-sweep
> algorithm (for non-weak references) in terms of SCC calculation was
> incorrect - I don't really think about this day-to-day anymore.  But,

This `do...while` loop can be a source of performance problems, indeed,
if we have many/large weak hash tables (i.e. many weak references) since
it's O(n²) for `n` weak references.

AFAIK, so far this has not been a problem (I suspect in practice it's
usually O(n) because we usually don't have many cycles between weak hash
tables), so any improvement would need to be "cheap" (both in terms of
code complexity and in terms of best-case CPU&heap cost).

> But, you can certainly calculate the SCCs of the "weakly-references *"
> (Kleene * operation intended) relation while recursing the entries of
> a weak hash table in one pass

I'm not sure that's the case because we don't know the full set of weak
references right from the start (or at least, in order to know the full
set, we'd have to traverse all the weak references before we know for
sure that they survive).


reply via email to

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