Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Markus Mottl" <markus.mottl@gmail.com>
To: "Gerd Stolpmann" <info@gerd-stolpmann.de>
Cc: "Erik de Castro Lopo" <mle+ocaml@mega-nerd.com>,
	caml-list@yquem.inria.fr
Subject: Re: [Caml-list] ANNOUNCE : libsndfile-ocaml alpha
Date: Tue, 2 Jan 2007 21:49:20 -0500	[thread overview]
Message-ID: <f8560b80701021849y400850f7q4430f87e14ed1707@mail.gmail.com> (raw)
In-Reply-To: <1167781575.8359.21.camel@localhost.localdomain>

[-- Attachment #1: Type: text/plain, Size: 2104 bytes --]

On 1/2/07, Gerd Stolpmann <info@gerd-stolpmann.de> wrote:
>
> Just a quick and somehow interesting observation: Linus assumes that the
> read buffer is page-aligned in this comparison, something you cannot
> expect in most higher languages (of course you can arrange that in
> libsndfile - did you?).


Right, this is an unwarranted assumption.  Furthermore, for certain
applications with complex access patterns I'd expect it to be way easier for
the user to use mmap efficiently.  Even assuming that "read" were always
faster, implementing your own complex buffer management to cache data
efficiently for particular access patterns may not be easy.  Unless your
name is Linus, of course... ;-)

That reminds me that the OS guys live in another
> world. Would be interesting which function wins if you compare Unix.read
> (which does not care about alignment, and does an extra copy) with
> Bigarray.mmap.
>

I use mmap in a fileserver for performance reasons.  Compared to using
I/O-channels it requires, if I remember correctly, only about 50% of the
CPU-time, but OCaml-channels have to do an extra copy from the channel
buffer to the user buffer so this is not quite a fair comparison.  I'd still
expect mmap to reduce overall CPU-time over "read" for larger files due to
less data copying between kernel buffers and user space.

I have observed that mmap does not pay for small files (my cutoff point is
8192 bytes), possibly due to some setup overhead for memory mappings.  Total
time is not strongly effected, because we are generally I/O-bound, but if
you run the fileserver on the same machine as applications, the lower
CPU-time is a noticable advantage.

There is one caveat though regarding mmap with OCaml on 32bit platforms: the
GC has a bug which prevents it from reclaiming bigarrays aggressively
enough.  Though there is plenty of RAM (the kernel need not keep mapped
files in memory), the process might run out of address space.  I hope this
bug (0004108) will be fixed in the next release.

Regards,
Markus

-- 
Markus Mottl        http://www.ocaml.info        markus.mottl@gmail.com

[-- Attachment #2: Type: text/html, Size: 2814 bytes --]

  parent reply	other threads:[~2007-01-03  2:49 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-22  4:54 Erik de Castro Lopo
2006-12-27  9:32 ` [Caml-list] " Vu Ngoc San
2006-12-27 10:10   ` Erik de Castro Lopo
2006-12-27 10:42     ` Erik de Castro Lopo
2006-12-30 21:07     ` Erik de Castro Lopo
2006-12-31  3:31       ` skaller
2006-12-31  4:23         ` Erik de Castro Lopo
2006-12-31 11:08           ` Richard Jones
2006-12-31 22:51             ` Erik de Castro Lopo
2007-01-01 14:53               ` Matthieu Dubuget
2007-01-01 19:58                 ` Erik de Castro Lopo
2007-01-02  0:51                   ` skaller
2007-01-02  1:14                     ` Erik de Castro Lopo
2007-01-02  5:26                       ` Erick Tryzelaar
2007-01-02  5:39                         ` Erik de Castro Lopo
     [not found]                       ` <1167765505.5341.12.camel@rosella.wigram>
2007-01-02 22:37                         ` Erik de Castro Lopo
2007-01-02 23:46                           ` Gerd Stolpmann
2007-01-03  1:59                             ` Pal-Kristian Engstad
2007-01-03  2:49                             ` Markus Mottl [this message]
2007-01-02  7:47                     ` Christoph Bauer
2006-12-31 19:05           ` skaller
2006-12-31 22:54             ` Erik de Castro Lopo
2007-01-02 10:56       ` Vu Ngoc San
2007-01-02 11:27         ` Erik de Castro Lopo
2007-01-02 19:39           ` David Baelde
2007-01-02 23:04             ` Erik de Castro Lopo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f8560b80701021849y400850f7q4430f87e14ed1707@mail.gmail.com \
    --to=markus.mottl@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=info@gerd-stolpmann.de \
    --cc=mle+ocaml@mega-nerd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox