Tuning Garbage Collection
CACAO currently uses the conservative Boehm GC in stop-the-world mode.
During loading and linking CACAO checks whether a class has any instance variables of reference type. If so, objects of this class are allocated as kind "NORMAL". Otherwise they are allocated as "PTRFREE". Arrays of references are allocated as "NORMAL", arrays of primitive types as "PTRFREE".
There are some possibilities for tuning the GC that have not been implemented, yet:
- Skipping the first two words of each object. These words always contain the vftbl pointer and the lock record pointer of the object. The GC does not need to push these onto the mark stack. (I tried this and it saves about 0.5% user time. -Edwin)
- Handing per-object layout information to the GC. The Boehm GC supports layout descriptors stored in the vftbls. Maybe creating these descriptors and making the GC use them would lead to better/faster GC. On the other hand the
Java heap is about 50% references and 50% ints (see FieldDataTypeFrequency), most of which probably dont look like pointers (ie. they are outside Boehm's plausible pointer range), so this may not be worth the trouble.