ANN: Dogelog Runtime, Prolog to the Moon (2021)

Mostowski Collapse bursejan at gmail.com
Sat Sep 18 17:28:54 EDT 2021


Yeah, it seems weak references could indeed spare
me mark_term(). But then I am stil left with sweep_trail().
I did not yet measure what takes more time mark_term()
or sweep_trail(). The displayed "gc" is the sum of both.

>From what I have seen, very large trail practically reduced
to a zero trail during Prolog GC, I am assuming that 
mark_term() is not the working horse. Usually mark_term()
only marks what is not-Garbage, and sweep_trail()

has to deal with Garbage and not-Garbage. And there
is usually a lot of Garbage, much more than not-Garbage.
Finding the objects that survive, is like finding the needle
in the haystack, except we do not have to scan the 

haystack, the needles are on the goal list. But afterwards,
the second pass, scanning the trail is the work of Heracles
cleaning the Augeas stables. This scan is trowing away the 
hay and keeping the needles.

Greg Ewing schrieb am Samstag, 18. September 2021 um 05:49:37 UTC+2:
> On 17/09/21 7:56 am, Mostowski Collapse wrote: 
> > The trail in Dogelog 
> > Runtime is a single linked list: 
> > 
> > -->[ A ]-->[ B ]-->[ C ]--> 
> > 
> > Now if B becomes unused, you need to rewire 
> > the trail, it should then look like: 
> > 
> > -->[ A ]---------->[ C ]-->
> Python has a way of creating weak references (see the weakref 
> module). You could set the trail up like this: 
> 
> -->[*]-->[*]-->[*]--> 
> | | | 
> v v v 
> [w] [w] [w] 
> : : : 
> v v v 
> [A] [B] [C] 
> 
> where [w] is a weak reference object. Then you could periodically 
> scan the trail looking for dead weakref objects and remove the 
> corresponding [*] node from the list. 
> 
> You can also attach callbacks to weakref objects that are triggered 
> when the referenced object dies. You might be able to make use of 
> that to remove items from the trail instead of the periodic scanning. 
> 
> -- 
> Greg


More information about the Python-list mailing list