<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2006/02/dab51431550d81c48172d697ed6abd7f"
  from="Xavier Leroy &lt;Xavier.Leroy@i...&gt;"
  author="Xavier Leroy"
  date="2006-02-08T15:17:40"
  subject="Re: [Caml-list] How to write efficient threaded programs on OCaml"
  prev="2006/02/ffd3c37c09ea8166f8864f74f592246e"
  next="2006/02/e372fc99b79b46a7af25cc560026115a"
  prev-in-thread="2006/02/ba69e3f637900ed5b9a81ab36432302a"
  next-in-thread="2006/02/13560aa4b6441de8642a3cc923b5bdb2"
  prev-thread="2006/02/e8e061a36eebffc17c3ac923c74535fc"
  next-thread="2006/02/38106d71003e52b2286dfdcb5936de4f"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="How to write efficient threaded programs on OCaml">
<msg 
  url="2006/02/2858f1e4532daae90d5b0762e3fff3cd"
  from="Christophe TROESTLER &lt;Christophe.Troestler@u...&gt;"
  author="Christophe TROESTLER"
  date="2006-02-07T23:15:58"
  subject="How to write efficient threaded programs on OCaml">
<msg 
  url="2006/02/8d4fd8575d33db86ab919dcb9d92ceb0"
  from="Erik de Castro Lopo &lt;ocaml-erikd@m...&gt;"
  author="Erik de Castro Lopo"
  date="2006-02-08T08:21:25"
  subject="Re: [Caml-list] How to write efficient threaded programs on OCaml">
<msg 
  url="2006/02/ba69e3f637900ed5b9a81ab36432302a"
  from="Christophe TROESTLER &lt;Christophe.Troestler@u...&gt;"
  author="Christophe TROESTLER"
  date="2006-02-08T14:38:22"
  subject="Re: [Caml-list] How to write efficient threaded programs on OCaml">
<msg 
  url="2006/02/dab51431550d81c48172d697ed6abd7f"
  from="Xavier Leroy &lt;Xavier.Leroy@i...&gt;"
  author="Xavier Leroy"
  date="2006-02-08T15:17:40"
  subject="Re: [Caml-list] How to write efficient threaded programs on OCaml">
<msg 
  url="2006/02/13560aa4b6441de8642a3cc923b5bdb2"
  from="Matthieu Dubuget &lt;matthieu.dubuget@l...&gt;"
  author="Matthieu Dubuget"
  date="2006-02-08T16:55:15"
  subject="Re: [Caml-list] How to write efficient threaded programs on OCaml">
</msg>
<msg 
  url="2006/02/69ecf29a7a4b470c82efbd9670ae271b"
  from="Christophe TROESTLER &lt;Christophe.Troestler@u...&gt;"
  author="Christophe TROESTLER"
  date="2006-02-08T22:13:44"
  subject="Re: [Caml-list] How to write efficient threaded programs on OCaml">
<msg 
  url="2006/02/58e39975dccbb2d8104ae347f9080a44"
  from="Alessandro Baretta &lt;a.baretta@b...&gt;"
  author="Alessandro Baretta"
  date="2006-02-09T17:49:04"
  subject="Re: [Caml-list] How to write efficient threaded programs on OCaml">
<msg 
  url="2006/02/778886ccf985c5e4118a759b4642a6fd"
  from="Matthew Hannigan &lt;mlh@z...&gt;"
  author="Matthew Hannigan"
  date="2006-02-09T23:24:32"
  subject="Re: [Caml-list] How to write efficient threaded programs on OCaml">
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2006/02/f6d6dd723dfe60f938c19fe88ed24c99"
  from="Florian Weimer &lt;fw@d...&gt;"
  author="Florian Weimer"
  date="2006-02-13T10:28:49"
  subject="Re: [Caml-list] How to write efficient threaded programs on OCaml">
<msg 
  url="2006/02/4cc1ecf5ea45bb6b9d9360127dbcac9e"
  from="Christophe TROESTLER &lt;Christophe.Troestler@u...&gt;"
  author="Christophe TROESTLER"
  date="2006-02-16T18:11:17"
  subject="Re: [Caml-list] How to write efficient threaded programs on OCaml">
</msg>
</msg>
</msg>
</thread>

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

Could you please tell us where to find the OCaml code you're
discussing?  I haven't seen it anywhere on the Web page you posted.

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

You've answered your own question: context switches with system
threads can be expensive depending on the characteristics of the
underlying POSIX threads implementation.  You're really testing
threading libraries, not language implementations.

My feelings at this point (without having seen the code nor the task
spec) is that you don't want to use threads at all, rather something
like CPS.

- Xavier Leroy

</contents>

</message>

