caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Markus Mottl <markus.mottl@gmail.com>
Cc: Damien Doligez <damien.doligez@inria.fr>,
	quant@janestcapital.com, caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] out-of-heap data structures [was: Regarding SMP computing]
Date: Wed, 27 Sep 2006 19:35:07 +0200	[thread overview]
Message-ID: <451AB64B.4030003@inria.fr> (raw)
In-Reply-To: <f8560b80609260737m20613c81l5e3d51ce65351a32@mail.gmail.com>

> But isn't it true that the GC doesn't follow pointers that point
> outside the OCaml-heap?  In that case it might be conceivable to copy
> OCaml-data that must not be reclaimed into the C-heap.

Yes, this is possible.  For instance, ocamlopt places structured
constants (e.g. constant lists) in the initialized data section
of the executable, outside the Caml heap.

> Of course,
> this would mean that pointers must not point back into the OCaml-heap
> from there, because there is no way the GC could know then that some
> value in the OCaml-heap is still in use, or how to update the pointer
> in the C-heap in case the OCaml-value gets moved around, e.g. during a
> compaction.

... unless you register the locations of back-pointers as global roots.
But be careful that global roots are scanned at every GC (minor as
well as major), therefore a large number of such roots slow down the
GC significantly.

> If the above really works,

There is one caveat: ad-hoc polymorphic primitives (structural
equality and comparisons, marshaling, hashing) will not work on data
structures that reside outside of the Caml heap.  The reason is that
these primitives treat out-of-heap pointers as opaque data.  There is
a special case (the "Is_atom" test) for pointers that correspond to
ocamlopt-generated static data, but extending this special case is
nonobvious.

> I'd be glad to know whether there is
> already functionality to copy OCaml-structures around.

Apparently, Richard Jones is already working on it...  Basically, it's
just like a copying collection with only one root.  You could draw
inspiration from the OCaml minor GC (Cheney-style breadth-first copying)
and from the marshaller (depth-first quasi-copying).

- Xavier Leroy


      parent reply	other threads:[~2006-09-27 17:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-25 12:13 Regarding SMP computing Jacques Carette
2006-09-25 13:40 ` [Caml-list] " skaller
2006-09-25 19:41 ` Richard Jones
2006-09-25 19:57   ` Yoann Padioleau
2006-09-27 21:10     ` David M. Cooke
2006-09-26 11:57   ` [Caml-list] " Damien Doligez
2006-09-26 14:37     ` Markus Mottl
2006-09-26 14:52       ` Christophe TROESTLER
2006-09-26 15:46         ` Markus Mottl
2006-09-26 15:01       ` Gerd Stolpmann
2006-09-26 18:56       ` Richard Jones
2006-09-27 12:14         ` Richard Jones
2006-09-27 16:05           ` Richard Jones
2006-09-27 17:35       ` Xavier Leroy [this message]

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=451AB64B.4030003@inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=damien.doligez@inria.fr \
    --cc=markus.mottl@gmail.com \
    --cc=quant@janestcapital.com \
    /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;
as well as URLs for NNTP newsgroup(s).