Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Re: OCaml is broken
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-12-27 (12:46)
From: Goswin von Brederlow <goswin-v-b@w...>
Subject: Re: [Caml-list] Re: multicore wish
Jon Harrop <> writes:

> On Thursday 24 December 2009 13:19:52 Goswin von Brederlow wrote:
>> Jon Harrop <> writes:
>> > No, in OCaml I fork every child. That is the only transparent way to give
>> > the child a coherent view of the heap but it is extremely slow (~1ms):
>> So if you add a (sleep 60) to the ocaml code then ocaml gets even
>> more worse than F#? You are comparing an implementation that is
>> specifically optimized to use things F# is good at and ocaml is
>> bad. To give a fair comparison you need to optimize the implementation 
>> to the language.
> Post a better OCaml solution if you can.
>> >> Each process then has a work queue which is works through. So they will
>> >> always use the local data. Only when a queue runs dry they steal from
>> >> another process and ruin locality.
>> >
>> > You are correctly describing the efficient solution based upon
>> > work-stealing queues that F# uses but OCaml cannot express it.
>> You mean that you didn't implement that way.
> No, I mean OCaml cannot express it.
>> I can easily express that with closures and pre-forked worker threads.
> OCaml's threads do not run in parallel so that will not work.

>> Or just implement it properly in ocaml. The problem part is the
>> GC. The rest is easy.
> No kidding.

There is one implementation:
But as said maybe not a verry good one.

I tried implementing parallel threads under the original GC by forking
multiple instances of the same program and using a Bigarray to mmap
/dev/null for shared memory between the instances. That works for
sharing primitive types, flat records (records of primitive types) and
even fixed (or bound) sized structures but it gets more and more
complex to share each and needs some Obj magic, marshaling or C stubs
(except for primitive types). It works but is a real hack.

I hope someone will pick up the pices and update OCaml4Multicore to
the latest ocaml or maybe for ocaml to add it directly. If not then I
fear ocaml will be left behind soon.