caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Richard Jones <rich@annexia.org>
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] Regarding SMP computing
Date: Tue, 26 Sep 2006 19:56:27 +0100	[thread overview]
Message-ID: <20060926185626.GA8522@furbychan.cocan.org> (raw)
In-Reply-To: <f8560b80609260737m20613c81l5e3d51ce65351a32@mail.gmail.com>

On Tue, Sep 26, 2006 at 10:37:27AM -0400, Markus Mottl wrote:
> On 9/26/06, Damien Doligez <damien.doligez@inria.fr> wrote:
> >The GC doesn't work by checking whether something has become
> >unreachable.  It works by marking all reachable data, then deallocating
> >everything else.  There is no way to do what you want in OCaml, and
> >I don't think it can be done without a major rework of the runtime
> >system.
> 
> 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.  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.
> 
> If the above really works, I'd be glad to know whether there is
> already functionality to copy OCaml-structures around.  We have some
> applications that would greatly benefit from this feature, too: they
> require an enormous amount of static background knowledge, and have to
> use it for small jobs which can be easily distributed.  We have
> multi-core, multi-processor machines, and would be able to greatly
> speed up our compute jobs if we could put these large OCaml-values
> into a shared-memory region.  It would save us both a hell lot of
> memory (probably in the range of GBs per machine for some jobs), and
> also make the GC work less hard marking data that is not going to be
> reclaimed anyway.

Really similar case to us!

In theory you'd have a "MARK_ANCIENT (obj)" operation.  It would copy
obj and everything pointed to by obj out of the OCaml heap into
malloc'd memory.  It would need to find everything pointing to obj and
update those pointers to the out-of-heap copy, or else have a proxy in
place of obj.  All done in C so that the garbage collector wouldn't be
running while this happened, and in Markus's case you'd want to move
out to some sort of shared memory, perhaps using something like
mmalloc[1].

The problem with all this is that such an "ancient" object had really
better not be changed.  If it was changed such that part of it pointed
to a new object allocated on the Caml heap, then that new object could
never be reached by the GC, and so would quickly get collected,
resulting in a dangling pointer.  You'd have to ensure that the
ancient object was never changed by careful programming ...

Rich.

[1] http://www.math.utah.edu/docs/info/mmalloc_1.html

-- 
Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology - http://merjis.com
Internet Marketing and AdWords courses - http://merjis.com/courses - NEW!
Merjis blog - http://blog.merjis.com - NEW!


  parent reply	other threads:[~2006-09-26 18:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-25 12:13 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 [this message]
2006-09-27 12:14         ` Richard Jones
2006-09-27 16:05           ` Richard Jones
2006-09-27 17:35       ` [Caml-list] out-of-heap data structures [was: Regarding SMP computing] Xavier Leroy
2006-09-26  1:41 [Caml-list] Regarding SMP computing Jonathan T Bryant

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=20060926185626.GA8522@furbychan.cocan.org \
    --to=rich@annexia.org \
    --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).