[rucksack-devel] Re: Rucksack, ECLM

Arthur Lemmens alemmens at xs4all.nl
Wed May 17 19:47:59 UTC 2006


Nikodemus wrote:

> * GC of live-in-lisp but dead-on-disk objects. I should just read the
>   code, I suppose, but what is the intended result here:
>
>     (with-rucksack ...
>       (let (x)
>          (with-transaction ()
>             (setf x (make-instance 'persistent-thing)))
>          ... do enough stuff to cause X to be GC'd from
>              the file...
>          (add-rucksack-root x ...)))
>
>   Does X get a new object-id, or what?

Good point; I discussed something similar with Martin Simmons during
the ECLM.   The short answer is that X doesn't get collected yet.

Here's a longer answer:

* Object table entries

One byte of each entry in the object table is reserved for garbage
collector information.  This garbage collector byte contains one of
the following serializer markers:

** free-block (#xB0)

This means that the corresponding object id is not in use at the
moment, and the block 'belongs to' the free list.

** live-object (#xB1)

This means that the corresponding object can be reached from one of
the garbage collector roots.

** dead-object (#xB2)

In the mark phase of a mark-and-sweep garbage collection, all live
objects are temporarily marked as dead.  If the scanner can reach the
object from one of the roots, it will be marked as alive during the
scan phase.  Otherwise, it will remain marked as dead until the
sweeper reaches the block; at that point, the block will be returned
to the free list and it will be marked as a free-block.

** reserved-object (#xB3)

Used for entries in the object table that belong to objects that
haven't been committed to disk yet.

The X in your example is a RESERVED-OBJECT as long as the transaction
hasn't committed yet, so it won't be collected by the GC.  When the
transaction commits, the marker will change to LIVE-OBJECT.  (At
least that's the plan; I think I haven't written the part that changes
the marker to LIVE-OBJECT at the moment.)

Only at the start phase of the *following* garbage collection round
will X be treated like a normal object: seen as alive if it can be
traced from the roots and as dead otherwise.

(It wouldn't surprise me if there were other problems similar to this
one that I haven't thought about yet.  This correspondence between
in-memory and on-disk stuff is rather tricky, and it's easy to forget
some subtle point.)

Arthur




More information about the rucksack-devel mailing list