lua-users home
lua-l archive

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


Thatcher Ulrich wrote:
> From a game programming perspective, an incremental collector
> is more crucial than lower overall overhead using a generational
> collector.

I agree with this, but will try to explain it more clearly.

First let's throw out the term "game programming" as too general.  A
graphical strategy game running on a PC is worlds apart from a first-person
action game running on a console.

The people most concerned about gc cpu performance are those writing
programs with hard real-time limits.  For example the main pass of the
program must complete within a video frame time.  Likely rationale for such
a limit are to avoid jerky animation, to deal with hardware limitations
(full resolution double buffer not available for interlace mode), or because
it's easier to code for a constant frame rate (and we are always in a
hurry).

In such a program, with Lua as it is now, you may as well force garbage
collection every frame (that is, call lua_setgcthreshold(L, 0)).  The
important quantity is the worst-case gc time over the life of the program
(or critical loop).  Forcing garbage collection will result in worst-case gc
time less than or equal to letting it happen automatically.

When Roberto mentions "shorter gc cycles" from a generational collector he
is referring to the average, correct?  That is certainly useful for programs
where total run time is a concern, but much less than a cure-all for those
struggling with hard real-time limits.

-John