From: Brian Hurt <bhurt@spnz.org>
To: Christophe Raffalli <christophe.raffalli@univ-savoie.fr>
Cc: Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp>,
<Christoph.Bauer@lms-gmbh.de>, <caml-list@inria.fr>
Subject: Re: AW: [Caml-list] The tag bit
Date: Fri, 13 Aug 2004 10:40:09 -0500 (CDT) [thread overview]
Message-ID: <Pine.LNX.4.44.0408131029000.4282-100000@localhost.localdomain> (raw)
In-Reply-To: <411CBAF6.3010101@univ-savoie.fr>
On Fri, 13 Aug 2004, Christophe Raffalli wrote:
> There is a less costly way to avoid the tag bit in integer:
> "conservative GC": any int which happens to point in an alloccated block
> (or only at the beginning if you do not consider C but ML) is considered
> as a pointer. You will have very few wrong pointers (especially in the
> second case). Moreover, array of int or float, or block of memory can be
> tagged with a flag saying they do not old pointer.
>
> The Boehm GC for C and C++ is very succefull to do that and very often
> allow you to share data-structure in C as you would in ML (not caring
> about who will release first the data) and gain both speed and memory.
This works well for languages like C/C++, where allocation is
(compartively) rare. Ocaml programs allocate like crazy (most of the
stuff they allocate becomes garbage almost immediately, which is why they
don't take 300 terabytes of ram to run). Cost of allocation is a very
important number to Ocaml's performance.
The problem with Boehm-style conservative GC is that you can't do copying
collection with it. You're not *sure* if that word is an integer or a
pointer, so you can't change it to move the object it's pointing to- you
might be changing an integer, with catastrophic consequences for the
program.
With copying garbage collection, allocation is very, very fast. Ocaml, on
the x86, takes five simple instructions to allocate a block of memory (if
you don't kick off a garbage collection). So a high allocation rate isn't
a big problem. But this only works because Ocaml keeps the heap compact
by moving objects around. So allocating on the heap is not much slower
than allocating on the stack- you just bump a pointer. If you can't move
objects around, the heap becomes fragmented- free and used blocks mixed
together. And you end up searching the heap for a free space when you
want to allocate. This isn't a problem if allocation is rare, but it's
deadly for Ocaml.
--
"Usenet is like a herd of performing elephants with diarrhea -- massive,
difficult to redirect, awe-inspiring, entertaining, and a source of
mind-boggling amounts of excrement when you least expect it."
- Gene Spafford
Brian
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next prev parent reply other threads:[~2004-08-13 15:32 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-12 15:22 Bauer, Christoph
2004-08-13 3:53 ` Jacques Garrigue
2004-08-13 12:58 ` Christophe Raffalli
2004-08-13 13:14 ` [Caml-list] Other GC in ML family ? Diego Olivier Fernandez Pons
2004-08-13 13:24 ` AW: [Caml-list] The tag bit Andreas Rossberg
2004-08-13 14:32 ` T. Kurt Bond
2004-08-13 14:41 ` AW: [Caml-list] Conservative GC T. Kurt Bond
2004-08-13 16:14 ` AW: [Caml-list] The tag bit Ville-Pertti Keinonen
2004-08-13 14:28 ` skaller
2004-08-13 15:44 ` Christophe Raffalli
2004-08-13 15:40 ` Brian Hurt [this message]
2004-08-13 13:43 Ennals, Robert
2004-08-13 14:58 Ennals, Robert
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.LNX.4.44.0408131029000.4282-100000@localhost.localdomain \
--to=bhurt@spnz.org \
--cc=Christoph.Bauer@lms-gmbh.de \
--cc=caml-list@inria.fr \
--cc=christophe.raffalli@univ-savoie.fr \
--cc=garrigue@kurims.kyoto-u.ac.jp \
/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