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=0.9 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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 3831ABB84 for ; Tue, 17 Feb 2009 11:07:20 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AicBAE8bmklQW+UCe2dsb2JhbACURQEBFiIEuzmEEwY X-IronPort-AV: E=Sophos;i="4.38,222,1233529200"; d="scan'208";a="21218421" Received: from main.gmane.org (HELO ciao.gmane.org) ([80.91.229.2]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES256-SHA; 17 Feb 2009 11:07:19 +0100 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1LZMrF-0004Cn-5i for caml-list@inria.fr; Tue, 17 Feb 2009 10:07:17 +0000 Received: from ks300734.kimsufi.com ([91.121.65.225]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 17 Feb 2009 10:07:17 +0000 Received: from sylvain by ks300734.kimsufi.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 17 Feb 2009 10:07:17 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: Sylvain Le Gall Subject: Re: Threads performance issue. Date: Tue, 17 Feb 2009 10:07:05 +0000 (UTC) Message-ID: 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=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ks300734.kimsufi.com User-Agent: slrn/pre0.9.9-102 (Linux) Sender: news X-Spam: no; 0.00; le-gall:01 ocaml:01 buffer:01 buffer:01 threads:01 char:01 wrote:01 unix:01 functions:01 remi:01 caml:02 threaded:03 std:03 blocking:04 channel:06 On 17-02-2009, RĂ©mi Dewitte wrote: > > test.csv is a 21mo file with ~13k rows and a thousands of columns on a 15rp= > m > disk. > > ocaml version : 3.11.0 > 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. I think it comes from reading using std IO channel which use 4k buffer. Using a bigger buffer will allow less call to this two functions (but you won't win time at the end, I think you will just reduce the difference between non-threaded and threaded code). Regards Sylvain Le Gall