From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Markus Mottl <markus.mottl@gmail.com>
Cc: ocaml <caml-list@inria.fr>, ocaml-users@janestcapital.com
Subject: Re: [Caml-list] Global roots causing performance problems
Date: Fri, 07 Mar 2008 15:10:05 +0100 [thread overview]
Message-ID: <47D14CBD.4060207@inria.fr> (raw)
In-Reply-To: <f8560b80803061551t46ae1748mb21abc8e8164727@mail.gmail.com>
> [GC overhead of having many global memory roots]
> We therefore wonder whether it wouldn't be much more effective to fix
> the runtime. I don't know the exact details of how things currently
> work, but I guess that it would be possible to have two separate sets
> of global roots for the minor and major heap. Then, once a value gets
> oldified, the global root, too, could wander to the corresponding set.
> The set for the major heap could then be scanned only once per full
> major cycle, maybe even in slices, too. Would this suggestion be easy
> to implement?
This "generational" approach is the natural solution to the problem
you mention. However, it is not compatible with the current API for
global root registration: when a program registers a "value *" pointer
using caml_register_global_root(), the program is free to change the
value contained in that placeholder at any time without notifying the
Caml memory manager. As a consequence, the minor GC has no choice but
scanning all global roots every time, because any of them could have
been overwritten with a freshly-allocated Caml block since the
previous minor GC.
There are 2 ways to go about this problem:
1- Change the specs of caml_register_global_root() to prohibit
in-place updates to the value contained in the registered value
pointer. If programmers need to do this, they must un-register the
value pointer, update its contents, then re-register it.
How much existing code would that break? I don't know.
2- Keep the current API for backward compatibility and add a
caml_register_global_immutable_root() function that would implement
generational scanning of global roots, in exchange for the
programmer's guarantee that the values contained in those roots are
never changed. Then, convince authors of Caml-C bindings to use the
new API.
I'm willing to implement any of these 2 approaches, but it is not a
transparent change in either case.
- Xavier Leroy
next prev parent reply other threads:[~2008-03-07 14:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-06 23:51 Markus Mottl
2008-03-07 14:10 ` Xavier Leroy [this message]
2008-03-07 14:52 ` [Caml-list] " Berke Durak
2008-03-07 16:45 ` Richard Jones
2008-03-07 17:05 ` Markus Mottl
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=47D14CBD.4060207@inria.fr \
--to=xavier.leroy@inria.fr \
--cc=caml-list@inria.fr \
--cc=markus.mottl@gmail.com \
--cc=ocaml-users@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