lua-users home
lua-l archive

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


----- Original Message -----
From: Tim Mensch
Date: 7/17/2013 10:31 AM
I do games. I have to do ALL of my upkeep, graphics set-up, AI calculations, etc., in 16.66ms or less, or it's going to skip a frame.

Yes, speed is still important. ;P

The only way things would be better for me (and games in general) is if LuaJIT had an optional reference-counted garbage collector. It seems that Lua CAN be modified to use one (see LuaPlus [1]), and the slight decrease in amortized performance would be more than offset (for needs of games) by the decreased memory required compared to mark-and-sweep and the increase in predictability of execution times.

[1] http://luaplus.org/#What-is-LuaPlus -- tl;dr: "An optional high performance reference counted garbage collector."
True story: Over the years, I've had a number of game companies approach me about bugs in LuaRC (the Lua reference counted version that isn't LuaPlus) and LuaPlus's reference counting.  The garbage collector running during their gameplay was unacceptable.

The simple truth is that for certain types of applications and especially mobile applications and games, reference counting is superior to garbage collection.  The deterministic nature of the reference counting keeps memory usage as low as possible, finalizes resources in a predictable fashion, and prevents the need for blips during gameplay when running garbage collection.  Benchmarks of the improved performance when garbage is being created have been posted on the list before.

I have not had time to port the reference counting forward to Lua 5.2, but I plan on updating LuaRC against Lua 5.3.

It would be considerable awesome, however, if reference counting could be a Lua core feature.  :) :) :)

-Josh