From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.2 required=5.0 tests=AWL,SPF_FAIL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id B831EBB84 for ; Tue, 17 Feb 2009 11:27:03 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAA8fmkkmachm/2dsb2JhbADQaIQTBg X-IronPort-AV: E=Sophos;i="4.38,222,1233529200"; d="scan'208";a="35307780" Received: from mx2.janestcapital.com ([38.105.200.102]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 17 Feb 2009 11:27:03 +0100 Received: from nyc-qsv-mail1.delacy.com ([172.25.22.57]) by mx2.janestcapital.com with esmtp (Exim 4.69) (envelope-from ) id 1LZNAL-0007Vo-GX for caml-list@inria.fr; Tue, 17 Feb 2009 05:27:01 -0500 Received: from nyc-qsv-004.delacy.com ([172.25.22.194] helo=qsmtp.delacy.com) by nyc-qsv-mail1.DELACY.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1LZNAL-0004dB-FB; Tue, 17 Feb 2009 05:27:01 -0500 Received: from lon-qws-008.delacy.com ([172.30.3.108] helo=lon-qws-008) by qsmtp.delacy.com with smtp (Exim 4.63) (envelope-from ) id 1LZNAK-0000qK-B4; Tue, 17 Feb 2009 05:27:01 -0500 Received: by lon-qws-008 (sSMTP sendmail emulation); Tue, 17 Feb 2009 10:26:59 +0000 From: "Mark Shinwell" Date: Tue, 17 Feb 2009 10:26:59 +0000 To: remi@gide.net Cc: caml-list@inria.fr Subject: Re: [Caml-list] Re: Threads performance issue. Message-ID: <20090217102659.GD29651@janestcapital.com> References: <2184b2340902160715y1f935b5ehc0e6195b3f75b66b@mail.gmail.com> <891bd3390902160847p25ad3bf1pe59da620dfc667f2@mail.gmail.com> <2184b2340902160937i53b8f3fbga01eaf14ed829f8f@mail.gmail.com> <2184b2340902162340s540c5ac7g9f42b59d03f643cb@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) X-Spam: no; 0.00; shinwell:01 buffer:01 hackery:01 runtime:01 2009:98 deceiving:98 threads:01 char:01 char:01 wrote:01 wrote:01 unix:01 caml-list:01 remi:01 remi:01 On Tue, Feb 17, 2009 at 10:07:05AM +0000, Sylvain Le Gall wrote: > On 17-02-2009, Rémi Dewitte wrote: > You are using input_char and standard IO channel. This is a good choice > for non-threaded program. But in your case, I will use Unix.read with a > big buffer (32KB to 4MB) and change your program to use it. As > benchmarked by John Harrop, you are spending most of your time in > caml_enter|leave_blocking section. This isn't quite right actually -- the profile is deceiving. It is true that there are a lot of calls to enter/leave_blocking_section, but you're actually being killed by the overhead of an independent locking strategy in the channel-based I/O calls. I've measured this using some hackery with a hex editor. When you call input_char, you acquire and then release another lock which is specific to these calls (the global runtime lock is often not released here). This process isn't especially cheap, so it would be better to use one of the other channel calls to read data in larger blocks. Mark