lua-users home
lua-l archive

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


Hi,

In  http://golang.org/s/gctoc, Rick Hudson and Austin Clements propose a new algorithm for improving GC: Transaction Oriented Collector (TOC) Algorithm.

> We propose a new garbage collection (GC) algorithm based on the transactional hypothesis. Put simply, the transactional hypothesis states that objects created by a transaction tend to die when the transaction ends. Our new transaction oriented collector or TOC algorithm focuses attention on these objects thus improving overall GC throughput and scalability while delaying the need to do a full heap GC.

[…]

>  The computation may access a large shared heap to read data, but typically writes very little to the heap that persists beyond the transaction. If at some point the goroutine does share newly allocated object with other goroutines, we call this publishing that object. If an object isn’t published, we call it local. The key observation of TOC is: if a goroutine exits before publishing an object, the object becomes unreachable and the associated memory can be reclaimed and reused immediately. The TOC algorithm is a way to promptly and efficiently reclaim these unpublished objects.

This looks slightly different from the ‘generational’ GC experimental feature in Lua 5.2. In particular, the criterion for early disposal of an object is not the creation order, but the ‘unpublished’ state of this object.

I was wondering if the same idea could not be transposed to Lua, by considering a value as ‘published’ if added to a table, used as an up-value or returned by a function. In other words, could a collectable value only used in one (or several) local variable(s) be released immediately at the end of the syntactic scope of these variables if not ‘published’?

If the answer is yes, this could lower significantly the GC pressure (and overhead) on well-written Lua code…

Any opinion on this?

Jean-Luc