From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 84008BBA7 for ; Wed, 8 Feb 2006 16:17:40 +0100 (CET) Received: from [128.93.11.95] (estephe.inria.fr [128.93.11.95]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k18FHX1G019191 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 8 Feb 2006 16:17:33 +0100 Message-ID: <43EA0B8D.6090906@inria.fr> Date: Wed, 08 Feb 2006 16:17:33 +0100 From: Xavier Leroy User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050322) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Christophe TROESTLER Cc: OCaml Mailing List Subject: Re: [Caml-list] How to write efficient threaded programs on OCaml References: <20060208.001547.81488614.Christophe.Troestler@umh.ac.be> <20060208192118.1755d70f.ocaml-erikd@mega-nerd.com> <20060208.153809.249505014.Christophe.Troestler@umh.ac.be> In-Reply-To: <20060208.153809.249505014.Christophe.Troestler@umh.ac.be> X-Enigmail-Version: 0.90.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 43EA0B8D.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml:01 mlton:01 ocaml:01 bytecode:01 threads:01 posix:01 threads:01 threading:01 slower:01 underlying:01 native:02 btw:02 cps:02 module:03 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 > 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 ??? 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. > P.S. BTW, these slowdowns especially happen with native code -- > bytecode (with -vmthreads) is immensely faster (of course this is a > 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