lua-users home
lua-l archive

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


	
	Hi, I've been trying to find ways to optimize the time it takes to
do one mark and sweep cycle on my project, long post below...

	The game I`m working on has a very high table/node count.  I'm
talking around 10 000 hash tables and 120 000 Nodes.  This takes a
relatively long time to traverse and causes the frame rate to drop
significantly when when doing a gc cylce ( it takes around 33ms to do the
complete gc ).

	I've been thinking about "quick and easy" solutions to improve this.
My idea that, I think, had the most potential was seperating my data as a
collectible and "uncollectable".  The idea is that anything that I know will
always be referenced until I close lua would be put in my uncollectable list
and marked right away so we don't need to traverse it during the mark phase.
I added a flag that I switch on or off in my game code and if the
noncollectible flag is on I place my new hashes in roottableNOGC.  Since the
tables are not in roottable they don't get traversed during the sweep phase
.  I also have a _NOGC version of the rootclosure, rootproto, rootudata.

	Naively I thought this would be a quick and painless bit of work
that would bring me good performance gains...  Unfortunately I'm still
pretty new to Lua and I was wrong.  Depending on what game data I decide to
make NonGCable I either get infinte loops in table traversals ( lua_Hnext()
) or crashes in the lvm when doing luaV_settable because the table it finds
has a negative number for size.. etc..

	I've thought about incremental garbage collection, but I'm a bit
hesitant to A : try to do my own incremental, B: port my project to lua 5.1.
If I can reduce the data set that goes through the garbage collection cycle
I would be ok I think.

	Has anyone ever tried something similar and made it work, or does
any one know if what I'm attempting is possible at all?  Also, if anyone has
suggestions on how to boost the performance of my GC update please let me
know.  Basically I need to improve the speed it takes for 1 mark and spweep
cycle.  

	Sorry for the long post, and thanks for any tips and hints.
	Yann Com-Nougué