Version française
Home     About     Download     Resources     Contact us    
Browse thread
How to write efficient threaded programs on OCaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Christophe TROESTLER <Christophe.Troestler@u...>
Subject: Re: [Caml-list] How to write efficient threaded programs on OCaml
On Wed, 8 Feb 2006, Erik de Castro Lopo <ocaml-erikd@mega-nerd.com> wrote:
> 
> This question (or variants of it) comes around quite regularly. The 
> standard response is:
> 
>     http://sardes.inrialpes.fr/~aschmitt/cwn/2002.11.26.html#8

Thanks for the link but I know about that answer (and sorry to start
yet again a discussion on this topic it's just that I can't figure out
why there is such a difference between programs using the same
concepts).  The test is supposed to be executed on a single processor
and can be seen as related to (2)-(3) [i.e. _not_ SMP] as there are 4
different threads -- one can think some are doing I/O, others are
listening to user events.  What is special about this test is that the
4 threads communicate a lot (this will obviously not be so intensive
in a real app but still lots of sync can happen).

My question is twofold.  When using the Event module in the same way
MLton does, the running time is ~30 times larger.  I'd like an
explanation about why there is such a huge difference and possible
ways to reduce it...  Using an implementation close to C (Mutex,
Condition) divides the time by 2 but still is about 6 times slower
than C.  Is it to say a better implementation is possible for OCaml ???

ChriS


---
P.S. BTW, these slowdowns especially happen with native code --
bytecode (with -vmthreads) is immensely faster (of course this is a
different implementation).