[Gc] Per-type displacement

Henning Makholm henning at octoshape.com
Fri Sep 19 06:17:41 PDT 2008


Ludovic Courtès writes:

> Registering a displacement globally for each value of N_EXTRA may lead
> to excess memory retention, especially since most other Guile objects
> ("cells") are 2 or 4 word long.

How so? Registered displacements that are larger than the size of objects
in the heap page pointed to do not count.

> Ideally, I'd create a `GC_desc' and somehow specify valid displacements
> that apply specifically to this type, which the `gc_typed.h' API
> currently doesn't allow.

This will be hard to implement efficitently, unless the typed-gc stuff
has changed fundamentally since I looked at it last.

There are separate heap pages for typed objects, byt objects with different
type information can share the same page (otherwise unacceptable slack
would occur for rarely-used types). The type information is stored in a
hidden word at the end of the allocated block. This is fine as long as
type information is used only for tracing the object itself - when that
happens the page will have be brought into RAM anyway.

However if one wants to use type information while tracing pointers TO
the object, this means that the marker has to access not only the page
header but also the page data in order to find out whether something is
a pointer. That might harm cache/paging performance, unless almost
everything that looks like a pointer turns out to BE a pointer to
something that must be traced later, in which case the whole exercise
is pointless anyway.

> Is it just that this allocation paradigm (returning a pointer in the
> middle of the object) is questionable?  :-)

What I suspect is questionable is your assumption that you want to avoid
GC_all_interior_pointers. Are you sure that it would be a problem just
to recognize all pointers?

If you're worried about false positives from tagged integers, it might
be an easier plan to hard-code an ad hoc "all pointers must be multiples
of 4" assumption into the marker than to try to give allocation types
separate displacement maps.

(However, it is not a priori clear that you need to worry about such
false positives in the first place. Integers that Scheme programs
manipulate are likely to be too small to be mistaken for pointers into
the garbage-collected heap most of the time).

--
Henning Makholm
Octoshape ApS



More information about the Gc mailing list