0x7CFE / llst

LLVM powered Little Smalltalk.
Other
93 stars 10 forks source link

Generational Garbage Collector is not working #6

Open 0x7CFE opened 11 years ago

0x7CFE commented 11 years ago

The Idea

Generational Garbage Collector (GGC) is a further evolution of the Baker Two Space collector which uses spaces in a more advanced way. Original Baker GC uses semi spaces in a symmetrical fashion: when one is almost filled, GC switches the spaces and moves all live objects to a new one, thus sweeping and compacting the space.

GGC tries to extend the efficiency of the two space allocation by preserving the long lasting objects on the same space as long as possible. This is achieved by defining to spaces as Young (left) and the Old (right) generations. New objects are spawned in the Young space only. When Young space is filled, survived objects are considered old enough to be moved to the Old space. Then Young space is cleared and reused.

This guarantees that Old space will not be disturbed until the very last collection in the Young heap which also fills the Old heap to the limit. Then objects are collected in the reverse order (both old and the fresh ones) and all of them are migrated to the Young heap.

All of this results in the asymmetrical collection rate of 10:1 and more. The less we move a lot of objects — the more speed efficient we'll be.

The Bug

Unfortunately, current implementation is not working as expected. moveYoungObjects() routine should only move objects from the Young heap that are referenced in the cross-heap list. Collecting only those objects is the main advantage comparing to the full heap traverse in the ordinary Baker.

Crash is eliminated if additional passes of root and external refs lists are added. However this makes no sense at all because it works even slower than the Baker.