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 E010DBBA7 for ; Wed, 8 Feb 2006 15:38:22 +0100 (CET) Received: from hedwig1.umh.ac.be (hedwig2.umh.ac.be [193.190.193.73]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k18EcMHm014681 for ; Wed, 8 Feb 2006 15:38:22 +0100 Received: from poincare (Debian-exim@poincare.swapping.umh.ac.be [10.102.100.28]) by hedwig1.umh.ac.be (8.13.1/8.13.1) with ESMTP id k18Ef9JN1597526; Wed, 8 Feb 2006 15:41:09 +0100 Received: from localhost ([127.0.0.1] ident=trch) by poincare with esmtp (Exim 4.60) (envelope-from ) id 1F6qSQ-0002r3-4q; Wed, 08 Feb 2006 15:38:10 +0100 Date: Wed, 08 Feb 2006 15:38:09 +0100 (CET) Message-Id: <20060208.153809.249505014.Christophe.Troestler@umh.ac.be> To: OCaml Mailing List Subject: Re: [Caml-list] How to write efficient threaded programs on OCaml From: Christophe TROESTLER In-Reply-To: <20060208192118.1755d70f.ocaml-erikd@mega-nerd.com> References: <20060208.001547.81488614.Christophe.Troestler@umh.ac.be> <20060208192118.1755d70f.ocaml-erikd@mega-nerd.com> X-Face: #2fb%mPx>rRL@4ff~TVgZ"<[:,oL"`TUEGK/[8/qb58~C>jR(x4A+v/n)7BgpEtIph_neoL KJBq0JBY9:}8v|j Organization: Universite de Mons-Hainaut (http://math.umh.ac.be/an/) X-Spook: advisors USCODE South Africa AFSPC terrorist Watergate Kh-11 tempest Yukon Nazi X-Blessing: Om Ah Hum Vajra Guru Pema Siddhi Hum X-Operating-System: GNU/Linux (http://www.linux.org/) X-Mailer-URL: http://www.mew.org/ X-Mailer: Mew version 4.2.53 on Emacs 22.0.50 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.1 (www dot roaringpenguin dot com slash mimedefang) X-Miltered: at nez-perce with ID 43EA025E.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml:01 christophe:01 troestler:01 christophe:01 troestler:01 umh:01 variants:01 sardes:01 inrialpes:01 aschmitt:01 threads:01 threads:01 mlton:01 ocaml:01 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 On Wed, 8 Feb 2006, Erik de Castro Lopo 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).