[plt-scheme] Some thoughts about GC and realtime aplications

From: Joe Marshall (jmarshall at alum.mit.edu)
Date: Mon May 22 15:08:22 EDT 2006

On 5/19/06, Ivan Boulanov <l00bis at mail.ru> wrote:
> Thank you for all your answers. You gave me very interesting information and
> I wonder why all these references have not been yet included to Scheme Wiki.
> It is a very, very interesting things especially for a little (beginner)
> schemer.
>
> Joe Marshall wrote:
> >3.  Modern computers have *lots* of RAM.
> If we treat such a techinical things relatively, we come to conclusion that
> there is no relative advantage for modern PCs over ancient ones.

You are free to draw any conclusion you wish, but I assure you that most people
find modern PCs to have several advantages over ancient ones.

> The more RAM amount and CPU time we get, the more we waste.

Are you saving it for some special occasion?

Some algorithms and techniques that were once considered impractical have
become commonplace because we *have* the RAM and CPU time we were
lacking.  The change in quantity has become so large that it makes a change
in quality.

> It is a banality. The
> question is how competitive would be a game with GC to those that use manual
> memory management? Modern big games (The Elder Scrolls III, Doom 3 etc.)
> have a very strong demands on how fast resources have to be allocated and
> how fast have to be freed. Modern games can not allow to waste a huge amount
> of RAM just because GC techique requires this. I think there really have to
> be a hybrid high-performance approach. I should consult the given
> references.

You should.  Some garbage collectors use time proportional to the amount of
live storage.  To the first order, the performance of the GC is
independent of the
size of RAM.  You'd be hard pressed to beat the performance for a large heap.


>
> And also you wrote:
> >> A completely different approach is to use reference-counting instead of
> >> GC.
> >> This approach is similar to the modern C++ programming approach of smart
> >> pointers.
> >
> >This, I think, is the wrong approach.  If you trace a program that
> >uses reference
> >counts, you'll notice that it spends a good chunk of time incrementing and
> >decrementing the refcounters.  This is spread rather evenly throughout the
> >program, so it doesn't introduce noticable pauses, but it does take up
> >processor
> >time.
> I don`t really believe in that because I use smart pointers (read as
> "reference counting") everywhere I can and there is only a negligible
> overhead over raw pointers. Maybe I miss something?

Measure it.

-- 
~jrm


Posted on the users mailing list.