lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Luiz -

There are some interesting lessons to learn from the work Python has
done on GC.

Historically Python was reference counted, making object deallocation
time very predictable -- although not collecting cycles. A few
versions ago they introduced a generational cycle finder. In the
latest version this cycle finder is enabled by default.

The interseting things about these scheme are:
 - ref-counting will immediately free non-cyclic stuff
 - it's easy to make the cycle-finder incremental, since 
   the refcounting is your write barrier
 - Python's implemention uses the fact that only collection
   types are involved in cycles. The cycle finder does not have
   to scan any non-collection types, eliminating lots of 
   objects from the sweep. In Lua, the only objects which can
   be involved in cycles are tables.
 - the overhead of the cycle finder is quite low (5-10% in
   some benchmarks)

Of course reference counting slows down the speed of assignment
instructions. However, as has been pointed out before, if we wanted
code to be 'really' fast it would be in C.

Anyhow... I hope this is a useful contribution to your thinking about
incremental collection schemes. I am interested in hearing your
throughts when you're ready to share them.

-- 
David Jeske (N9LCA) + http://www.chat.net/~jeske/ + jeske@chat.net