caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alessandro Baretta <a.baretta@barettadeit.com>
To: Christophe TROESTLER <Christophe.Troestler@umh.ac.be>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] How to write efficient threaded programs on OCaml
Date: Thu, 09 Feb 2006 18:39:05 +0100	[thread overview]
Message-ID: <43EB7E39.2010804@barettadeit.com> (raw)
In-Reply-To: <20060208.231335.161803011.Christophe.Troestler@umh.ac.be>

[-- Attachment #1: Type: text/plain, Size: 1862 bytes --]

Christophe TROESTLER wrote:
> On Wed, 08 Feb 2006, Xavier Leroy <Xavier.Leroy@inria.fr> wrote:
> 
>>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.
> 
> 
> Sorry.  You get the code by clicking on the language name:
> http://shootout.alioth.debian.org/gp4/benchmark.php?test=chameneos&lang=all
> The task description is at the bottom of the page.
> 
> The one similar to MLton is:
> http://shootout.alioth.debian.org/gp4/benchmark.php?test=chameneos&lang=ocaml&id=0

Wow! It's incredible to see just how slow an algorithm can become when threading 
is used. A vanilla userland scheduler can produce a three-order of magnitude 
speedup over a threading library. I'm attaching an implementation of chameneos 
which uses a batched queue à la Okasaki to schedule chameneos meetings. 
Obviously, this algorithms is absolutely deterministic, while the implementation 
using threads follows a random execution path, which is in general different at 
every execution of the program. Yet the program satifies the benchmark 
specification and is about 700 times faster than
http://shootout.alioth.debian.org/gp4/benchmark.php?test=chameneos&lang=ocaml&id=0

I have used this approach to write my Schopenhauer software PLC in Ocaml. This 
is one of the key design factors for achieving realtime performance without 
hogging the CPU.

Yet, what conclusion should I draw? Is the GNU/Debian/Linux-2.6 threading 
support creepingly slow, or does ocaml have an insurmountable aversion for threads?

Alex

-- 
*********************************************************************

Ing. Alessandro Baretta

Studio Baretta
http://studio.baretta.com/

Consulenza Tecnologica e Ingegneria Industriale
Technological Consulting and Industrial Engineering

tel. +39 02 370 111 55
fax. +39 02 370 111 54


[-- Attachment #2: chameneos_alex.ml --]
[-- Type: application/x-extension-ml, Size: 2065 bytes --]

  reply	other threads:[~2006-02-09 17:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-07 23:15 Christophe TROESTLER
2006-02-08  8:21 ` [Caml-list] " Erik de Castro Lopo
2006-02-08 14:38   ` Christophe TROESTLER
2006-02-08 15:17     ` Xavier Leroy
2006-02-08 16:58       ` Matthieu Dubuget
2006-02-08 22:13       ` Christophe TROESTLER
2006-02-09 17:39         ` Alessandro Baretta [this message]
2006-02-09 22:26           ` Matthew Hannigan
2006-02-13 10:25 ` Florian Weimer
2006-02-16 18:11   ` Christophe TROESTLER

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=43EB7E39.2010804@barettadeit.com \
    --to=a.baretta@barettadeit.com \
    --cc=Christophe.Troestler@umh.ac.be \
    --cc=caml-list@yquem.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).