caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "forum@x9c.fr" <forum@x9c.fr>
To: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] "ok with parallel threads" GC (aka ocaml for multicore)
Date: Sat, 18 Apr 2009 01:05:33 +0200	[thread overview]
Message-ID: <16A3CF1D-0D89-40B5-B77F-AD936FF67271@x9c.fr> (raw)
In-Reply-To: <5409216D-4094-424B-BEEE-3AC3701A87DD@lip6.fr>


Le 18 avr. 09 à 00:15, Philippe Wang a écrit :

>
> On Apr 16, 2009, at 11:45 CEDT, Philippe Wang wrote:
>
>>> A negative answer would imply that you patched the OCaml
>>> runtime to make it reentrant. To illustrate my point, I will take
>>> the example of the file "byterun/compare.c". In this file, the
>>> code for the comparison of values makes use of a global
>>> variable (named "caml_compare_unordered").
>>
>> It should be, unless bugs are still hiding under that.
>> It is supposed to have been done for a while. We'll make one more  
>> check.
>>
>>> If you patched the runtime to allow multiple threads to use
>>> it concurrently, I would also be interested by the strategy
>>> used: is the problem solved by additional parameters ?
>>> by the use of thread-local storage ? by any other mean ?
>>
>> - local variable instead of global variable in functions
>> - some functions are parameterized by thread identifier (that is,  
>> one more parameter than "before") (e.g. in amd64.S)
>
> Well, we went back into runtime code implementation.
>
> This is what can be said rapidly :
> - compare.c contains no global variables anymore, we use local  
> variables instead
> - if a Caml-C or C-Caml interface uses caml_compare_unordered, we  
> don't know what can happen with parallel threads
> - we have many global mutex locks with small scopes
> - we do use an "enter/leave blocking section" mechanism to prevent  
> the GC from waiting on a blocking operation such as I/O or mutex  
> locking etc.
> - we don't support weak values (not sure whether they don't work or  
> they became strong, if they dont work anymore, they can be back in 2  
> minutes as strong values anyway)
> - serialisation of values is a little bit tricky, though it should  
> work
> - most important : many global variables do not exist anymore  
> because they are irrelevant in our implementation
> - we do not support unofficial-features of ocaml 3.10, e.g. the new  
> features that come with 3.11 but actually have their roots in  
> previous versions
> ~ it is almost sad to see all the based-on-"one-thread-at-a-time"  
> optimisations removed...
> + (it looks like it works just fine)
>
>
> I hope there are no "hidden" bad global variables.
>
> Is it fully reentrant ? Hmmmm... maybe.
>
> We use a stop-the-world GC (which means no one is running is  
> parallel with the GC), that is actually like original ocaml, that  
> comes with its inconveniences : C calls not declared as blocking  
> sections (which has quite a cost) may prevent other threads from  
> running when the heap is full.
>
> Graphics module, for instance, is not reentrant at all (anyhow it's  
> not part of the runtime). Same for Str.


I was indeed mostly worried with the runtime itself. I wanted to have  
a fully reentrant runtime for the OCaml-Java
project (to be able to execute several programs in the very same JVM)  
and remember that it implied primitives
from "compare.c", "hash.c", "intern.c" and "extern.c" among others to  
be written differently for this purpose.

Out of curiosity: you state that your GC is of "stop-the-world"  
nature, what about finalizers ?
Are they executed by the GC thread when the world is stopped or  
concurrently with
application threads ?
Not sure this question really matters, just curious (I mean, it is  
doubtful that one would write finalizers with
a long execution time).


Keep up the good work !

Xavier Clerc

  parent reply	other threads:[~2009-04-17 23:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-10 17:04 Philippe Wang
2009-04-10 20:52 ` [Caml-list] " Jon Harrop
2009-04-10 23:20 ` Jerome Benoit
     [not found] ` <BB3C091F-3BE9-4883-A7CF-9D672CDDF829@x9c.fr>
2009-04-14 10:21   ` Philippe Wang
2009-04-14 14:18     ` xclerc
2009-04-16  9:45     ` Philippe Wang
2009-04-17 22:15       ` Philippe Wang
2009-04-17 22:20         ` Joel Reymont
2009-04-17 22:29           ` Philippe Wang
2009-04-17 23:05         ` forum [this message]
2009-04-23 16:49         ` Philippe Wang

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=16A3CF1D-0D89-40B5-B77F-AD936FF67271@x9c.fr \
    --to=forum@x9c.fr \
    --cc=caml-list@inria.fr \
    /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).