This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: garbage collection pauses: too long for a game?


Kalle Niemitalo <tosi@ees2.oulu.fi> writes:

 > hjstein@bfr.co.il (Harvey J. Stein) writes:
 > 
 > > I wrote a tetris program in scheme (stetris) using STk. The GC pauses
 > > were somewhat annoying until I a) increased the initial heap size (to
 > > make GC less frequent)
 > 
 > Does this also make the pauses longer?

With STk I think it did, but I can't recall.  But, when a
block is falling a GC is very noticible.  Afterwards it isn't.  In
fact, there was a built in pause at that point so a little extra from
the GC didn't matter.

 > > and b) forced gc by executing (gc) at times when variable gc pauses
 > > weren't noticeable,
 > 
 > Does GC frequency have any effect on the length of the pauses?

Depends on the gc & the program behavior.  Eg - a stop & copy gc only
visits the live data.  If a program creates lots of garbage but always
has a small working set then gc will always take the same amount of
time no matter how often it's called (aside from memory cache
effects).

With a mark & sweep gc in the above situation everything gets visited
so total gc time per unit of running time will be about the same,
except for the extra visiting of the live data.  But it'd be much
slower than the stop & copy.

On the other hand, if you have lots of live data & very little
garbage, then mark & sweep would be more efficent because it doesn't
have to do the extra relocation work that stop & copy does.

However, a generational gc would fix that because it would stop
rescanning the stuff that's been around for awhile.

In any case, the total overhead of gc can often be lower than the
overhead of explicit use of malloc/free, so the only loss is that all
the work is bundled up into 1 chunk of time.  It also typically isn't
a large amount of time.  Depending on the game, the gc & how the gc is
used/tuned, this may or may not be a problem.

I guess guile is mark & sweep, but the real answer is "try it & see".

-- 
Harvey J. Stein
BFM Financial Research
hjstein@bfr.co.il