lua-users home
lua-l archive

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


> > reference counted garbage collection (built on the mark-sweep 
> > allocator... it does WONDERS for real-time performance)
> 
> One of the concerns with reference counting is the cost of 
> manipulating reference counts. Are you doing anything 
> particularly clever or is this a relatively naïve reference 
> counting implementation?

It's a very simple solution that, for everything I've thrown at it, works
very well.  While I'm not happy with the amount of testing I've done on it,
I will post a version for people's perusal this evening.  I also have
realized I'm not up to date with weak key and value behavior collection
behavior.  Nevertheless, the performance is awesome.  For this very simple,
contrived (and impractical) case, on my 2.8 GHz HT Pentium 4, the following
code takes 8 seconds with the mark-sweep collector.  It takes 2 with the ref
counting collector:

for i = 1, 1000000 do myTable = {} end

Cycles aren't handled, and if they exist, you have to call the primary
mark-sweep collector.  In a check through thousands of lines of script, I
only had just a few cycles.

I was curious about the ref counted collection when I was looking through
the language Squirrel (http://squirrel.sourceforge.net/).  I threw all sorts
of cases at the ref counting collector, and it worked really well.  I had to
try it in Lua, and I also believe it works well there, too.

Anyway, I'll post tonight.

Josh