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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 63306BBAF for ; Mon, 25 Oct 2010 17:34:42 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjkBANM/xUzRVde2kWdsb2JhbACDH543CBYBAQEJCwoHEQMfoWGIJ3U8CoINhiIuiFcBAQMFhE90BIpNg0qEYg X-IronPort-AV: E=Sophos;i="4.58,236,1286143200"; d="scan'208";a="84538105" Received: from mail-ey0-f182.google.com ([209.85.215.182]) by mail1-smtp-roc.national.inria.fr with ESMTP; 25 Oct 2010 17:34:42 +0200 Received: by eyb7 with SMTP id 7so1810498eyb.27 for ; Mon, 25 Oct 2010 08:34:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:reply-to :in-reply-to:references:date:message-id:subject:from:to:content-type; bh=koR5j3eI16QIRz/YcQKHf4ZZMFxlQyiy7GNhNtPawXo=; b=r0wJQA+9dBJZpFVVHdVOmEhSI+5+v82rnIHJacLfqITOeX7/d7SIewtwMO59MYFk59 XzAreh2f0D0AY1wufFpGeh6KPmOkX7MfClt15Dqug4ReazSJw9fMNj5bC0RU6ykUhUOG JUWctcyd4ZmUSgTRNTb8BXzq0mbDNaE/SmgoQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:content-type; b=FYNwnZ/lOSEL5og/tVYH0RlxG2dNt2toAaWcA2pTtdkwLEGnSIYG/X6l5IUj2CX7zk EtyzGpnd4wBerR6TVLf7z/9TMZ8y81For9rZ32BtY160VkD6l8fNqAhv6m5qB7FKd/+8 SoMYXw6en9V6U80pCqSE20is/N/Nsz28M3lv8= MIME-Version: 1.0 Received: by 10.216.56.18 with SMTP id l18mr521071wec.36.1288020881675; Mon, 25 Oct 2010 08:34:41 -0700 (PDT) Received: by 10.216.67.21 with HTTP; Mon, 25 Oct 2010 08:34:41 -0700 (PDT) Reply-To: yminsky@gmail.com In-Reply-To: <20101025143317.GB32282@aurora> References: <044101cb7367$10f94b30$32ebe190$@com> <20101024225037.GA8999@aurora> <87y69mk6jm.fsf@frosties.localdomain> <20101025111022.GA32282@aurora> <20101025143317.GB32282@aurora> Date: Mon, 25 Oct 2010 11:34:41 -0400 Message-ID: Subject: Re: [Caml-list] Asynchronous IO programming in OCaml From: Yaron Minsky To: =?ISO-8859-1?Q?J=E9r=E9mie_Dimino?= , caml-list@inria.fr Content-Type: multipart/alternative; boundary=0016e6d566871d948c049372bb04 X-Spam: no; 0.00; ocaml:01 yaron:01 minsky:01 yminsky:01 yaron:01 minsky:01 iteration:01 iteration:01 threads:01 threads:01 wrote:01 wrote:01 caml-list:01 caml:02 caml:02 X-Attachments: cset="UTF-8" cset="UTF-8" --0016e6d566871d948c049372bb04 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Sorry, didn't meant to take this off list. Taking it back to the caml list. I don't quite understand how this whole benchmark holds together. Could yo= u post the C code? I don't understand the differences between (1), (2) and (3) well enough to explain where the factor of 100 comes in. y On Mon, Oct 25, 2010 at 10:33 AM, J=C3=A9r=C3=A9mie Dimino wrote: > On Mon, Oct 25, 2010 at 07:59:17AM -0400, Yaron Minsky wrote: > > What's the advantage of using mmap here?=EF=BF=BD Why not just have = a few > worker > > threads available for doing file io?=EF=BF=BD Then you can use the o= rdinary > file > > API, and you don't need to spin up a brand new thread for each > request. > > It because the cost of switching to another thread is too big. I did the > following benchmarks some time ago (in C): i made three programs reading > a 100Mo file using a loop in the following way: > > 1 - just use read, without threads > 2 - launch a thread at each iteration > 3 - use only one thread created before entering the loop > > And the results were the following: > > - in any case (2) and (3) gave the same result, > - when the file was not in the cache, the execution time was the same > for the three programs, > - when the file was in the cache, (2) and (3) were about 100 times > slower than (1) > > J=C3=A9r=C3=A9mie > --0016e6d566871d948c049372bb04 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Sorry, didn't meant to take this off list. Taking it back to the caml l= ist.

I don't quite understand how this whole benchmark holds tog= ether.=C2=A0 Could you post the C code?=C2=A0 I don't understand the di= fferences between (1), (2) and (3) well enough to explain where the factor = of 100 comes in.

y

On Mon, Oct 25, 2010 at 10:33 AM, J= =C3=A9r=C3=A9mie Dimino <jeremie@dimino.org> wrote:
On Mon, Oct 25, 2010 at 07:59:17AM -0400, Yaron Minsky wr= ote:
> =C2=A0 =C2=A0What's the advantage of using mmap here?=EF=BF=BD Why= not just have a few worker
> =C2=A0 =C2=A0threads available for doing file io?=EF=BF=BD Then you ca= n use the ordinary file
> =C2=A0 =C2=A0API, and you don't need to spin up a brand new thread= for each request.

It because the cost of switching to another thread is too big. I did = the
following benchmarks some time ago (in C): i made three programs reading a 100Mo file using a loop in the following way:

1 - just use read, without threads
2 - launch a thread at each iteration
3 - use only one thread created before entering the loop

And the results were the following:

- in any case (2) and (3) gave the same result,
- when the file was not in the cache, the execution time was the same
=C2=A0for the three programs,
- when the file was in the cache, (2) and (3) were about 100 times
=C2=A0slower than (1)

J=C3=A9r=C3=A9mie

--0016e6d566871d948c049372bb04--