From: Thatcher Ulrich <tu@tulrich.com>
To: Chris Hecker <checker@d6.com>
Cc: Daniel Phillips <dan@dgph.net>, <caml-list@inria.fr>
Subject: Re: [Caml-list] Ocaml and games
Date: Fri, 25 Jan 2002 18:00:30 -0500 (EST) [thread overview]
Message-ID: <Pine.BSF.4.30.0201251736490.41444-100000@mini.pair.com> (raw)
In-Reply-To: <4.3.2.7.2.20020125141112.030791f0@arda.pair.com>
On Fri, 25 Jan 2002, Chris Hecker wrote:
> > The GC performance predicability and smoothness is a huge looming
> > shadow on the horizon that may or may not materialize, I have no
> > idea. Do you have any specific thoughts on this that you can
> > share yet? Have you done any tests?
>
> Nope. It's just that the "conventional wisdom" is that GC will hurt
> performance, so I'm worried just on principle. :) I haven't seen any
> indication that it will yet, however.
>
> As the other poster said, doing full collections between levels
> seems like a reasonable thing to try.
>
> I'm also slightly worried about the "write barrier" thing, which
> I've seen posted about but don't fully understand yet. To avoid GC
> activity I may want to keep some arrays around and reuse them, but
> apparently as they migrate into the old heap then you get the write
> barrier thing going on. Hopefully this won't be a problem either,
> but I don't know yet (I don't know if I understand it correctly yet,
> either).
I have no real-world experience to share concerning OCaml's garbage
collector, but there's an informal description of how it works here:
http://para.inria.fr/~doligez/caml-guts/Sestoft94.txt
It's linked off the "Papers" section of the OCaml web site:
http://caml.inria.fr/ocaml/papers.html
Anyway, I'll speculate, because I've long pondered using GC in games:
based on that description, OCaml's GC is *exactly* the ideal type of
collector for interactive games. It's generational, which is good for
overall efficiency, and the old generation is collected incrementally,
which means it processes a single "chunk" at a time, rather than the
full heap. I haven't even looked at the API, but in theory the ideal
way to run a collector like this in a double-buffered game program
(like many console games) is to:
1) make sure the worst-case time to process a chunk is under say 2ms.
Do this by sizing the chunks appropriately or whatever. Disclaimer: I
have no idea what Ocaml GC's real-world latency is for processing a
chunk.
2) at the end of rendering, before displaying the back buffer, look at
the timer and decide whether you have 2ms to spare before the next
vsync. If so, then run the GC for one chunk -- it's practically free.
If not, then don't; hopefully you'll catch up in subsequent frames.
Basically, if your average allocation rate is below some threshold
(and you have some extra room on the heap to amortize any peaks), and
you run the GC enough, you'll *never* see a GC pause.
If you're triple-buffered, or you don't wait for vsync, then this
trick doesn't work, but in those cases you probably care much less
about an extra 2ms GC latency now and then.
The deal with a write barrier is that any time you write to a pointer
variable that's stored in the old generation of the heap, the GC must
know about it (so it can keep its incremental state synchronized). If
you're reading, or just writing data variables, the write barrier
should be irrelevant (although I don't know how it's implemented in
practice, so I'll shut up now).
-Thatcher
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
next prev parent reply other threads:[~2002-01-25 23:00 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-01-21 23:27 cgillot
2002-01-21 22:43 ` [Caml-list] Re: your mail Markus Mottl
2002-01-22 0:03 ` [Caml-list] Re: about toplevels cgillot
2002-01-22 20:41 ` Chris Hecker
2002-01-22 21:35 ` [Caml-list] Ocaml and games Matthew D Moss
2002-01-22 21:43 ` Will Benton
2002-01-22 23:53 ` Eric C. Cooper
2002-01-23 0:58 ` Ian Zimmerman
2002-01-23 1:23 ` Yaron M. Minsky
2002-01-23 3:29 ` Doug Bagley
2002-01-23 5:20 ` Chris Hecker
2002-01-24 3:02 ` Matthew D Moss
2002-01-24 6:59 ` Chris Hecker
2002-01-25 20:22 ` Daniel Phillips
2002-01-25 20:53 ` Ken Rose
2002-01-25 22:16 ` Chris Hecker
2002-01-25 23:00 ` Thatcher Ulrich [this message]
2002-01-23 8:39 ` Sven
2002-01-23 15:35 ` Xavier Leroy
2002-01-22 9:00 ` [Caml-list] Re: your mail Daniel de Rauglaudre
2002-01-22 13:12 ` Markus Mottl
[not found] ` <4.3.2.7.2.20020123011902.00cde840@arda.pair.com>
2002-01-23 9:35 ` [Caml-list] Re: about toplevels Christian Gillot
2002-01-23 10:20 ` Chris Hecker
2002-01-24 16:03 ` Daniel de Rauglaudre
2002-01-24 17:20 ` Christophe Raffalli
2002-01-24 17:34 ` Christian Gillot
2002-01-24 20:42 ` [Caml-list] gotchas [Was: toplevels] Ian Zimmerman
2002-01-25 10:59 ` Christian Gillot
2002-01-25 11:17 ` Sven
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.BSF.4.30.0201251736490.41444-100000@mini.pair.com \
--to=tu@tulrich.com \
--cc=caml-list@inria.fr \
--cc=checker@d6.com \
--cc=dan@dgph.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox