caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jon Harrop <jonathandeanharrop@googlemail.com>
To: "'Eray Ozkural'" <examachine@gmail.com>,
	"'Sylvain Le Gall'" <sylvain@le-gall.net>
Cc: <caml-list@inria.fr>
Subject: RE: [Caml-list] Re: How to re-implement the GC?
Date: Mon, 13 Sep 2010 22:25:37 +0100	[thread overview]
Message-ID: <009601cb538a$3be05160$b3a0f420$@com> (raw)
In-Reply-To: <AANLkTi=9d4A=aUyhQEhu6KgjQ4bhTd3by_cXbyy0Ew0U@mail.gmail.com>

Hi Eray,

Retrofitting a new multicore-friendly GC onto OCaml is difficult for two
main reasons:

1. You want plug-and-play GCs but the OCaml compiler is tightly coupled to
the old GC (although OC4MC has decoupled them!).

2. Recovering similar performance whilst reusing the same data
representation is extremely difficult because the current design relies so
heavily on lightweight allocation. You really want to change the data
representation to avoid unnecessary boxing (e.g. never box or tag int,
floats or tuples) in order to reduce the allocation rate and, consequently,
the stress on the garbage collector but OCaml cannot express value types and
its ability to represent polymorphic recursion makes this extremely
difficult to implement.

As Sylvain has said, OC4MC is your best bet if you want to try to write a
new GC for OCaml. However, making more extensive changes has the potential
to address many more problems (e.g. convey run-time type information for
generic printing) so you might consider alternatives like trying to compile
OCaml's bytecode into HLVM's IR for JIT compilation because HLVM already has
a multicore friendly GC and it is much easier to develop.

> Ah, that's interesting. I wonder if it provides any real speedup on new
> architectures compared to storing the pointer in RAM.

For a multicore GC, using a register to refer to thread-local data is a huge
win because accessing thread-local data is very slow. I made that mistake in
HLVM's first multicore-capable GC and it was basically useless as a
consequence because all of the time was spent looking up thread-local data.
When I started passing the thread-local data around as an extra argument to
every function (not necessarily consuming a register all the time because
LLVM is free to spill it), performance improved enormously.

Cheers,
Jon.



  parent reply	other threads:[~2010-09-13 21:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-13  6:29 Eray Ozkural
2010-09-13  7:57 ` Sylvain Le Gall
2010-09-13 12:02   ` [Caml-list] " Eray Ozkural
2010-09-13 12:22     ` Sylvain Le Gall
2010-09-13 14:14       ` [Caml-list] " Eray Ozkural
2010-09-13 14:29         ` Sylvain Le Gall
2010-09-13 21:25           ` [Caml-list] " Jon Harrop
2010-09-13 21:25         ` Jon Harrop [this message]
2010-09-13 21:47           ` Eray Ozkural

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='009601cb538a$3be05160$b3a0f420$@com' \
    --to=jonathandeanharrop@googlemail.com \
    --cc=caml-list@inria.fr \
    --cc=examachine@gmail.com \
    --cc=sylvain@le-gall.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;
as well as URLs for NNTP newsgroup(s).