From: Sylvain Le Gall <sylvain@le-gall.net>
To: caml-list@inria.fr
Subject: Re: Threads performance issue.
Date: Tue, 17 Feb 2009 17:14:04 +0000 (UTC) [thread overview]
Message-ID: <slrngpls2s.e8q.sylvain@gallu.homelinux.org> (raw)
In-Reply-To: <891bd3390902170420i6e7647ccl44c55456952d3f5a@mail.gmail.com>
Hello,
On 17-02-2009, Yaron Minsky <yminsky@gmail.com> wrote:
>
> Interestingly, this probably has nothing to do with the size of the buffer.
> input_char actually acquires and releases a lock for every single call,
> whether or not an underlying system call is required to fill the buffer.
> This has always struck me as an odd aspect of the in/out channel
> implementation, and means that IO is a lot more expensive in a threaded
> context than it should be.
>
>
> On Tue, Feb 17, 2009 at 5:07 AM, Sylvain Le Gall <sylvain@le-gall.net>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. 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).
>>
You are probably true concerning the fact that it has nothing to do with
size of the buffer. I am just mixing two kind of optimization. Anyway, I
think even if the size is not important, using Unix.read + file
descriptor should do the trick.
Thanks for your detailed explanation.
Regards
Sylvain Le Gall
prev parent reply other threads:[~2009-02-17 17:14 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-16 15:15 Rémi Dewitte
2009-02-16 15:28 ` [Caml-list] " Michał Maciejewski
2009-02-16 15:32 ` Rémi Dewitte
2009-02-16 15:42 ` David Allsopp
2009-02-16 16:07 ` Rémi Dewitte
2009-02-16 16:32 ` Sylvain Le Gall
2009-02-17 13:52 ` [Caml-list] " Frédéric Gava
2009-02-16 16:47 ` [Caml-list] " Yaron Minsky
2009-02-16 17:37 ` Rémi Dewitte
2009-02-17 7:40 ` Rémi Dewitte
2009-02-17 8:59 ` Mark Shinwell
2009-02-17 9:09 ` Rémi Dewitte
2009-02-17 9:53 ` Jon Harrop
2009-02-17 10:07 ` Sylvain Le Gall
2009-02-17 10:26 ` [Caml-list] " Mark Shinwell
2009-02-17 10:50 ` Rémi Dewitte
2009-02-17 10:56 ` Mark Shinwell
2009-02-17 11:33 ` Jon Harrop
2009-02-17 12:20 ` Yaron Minsky
2009-02-17 12:26 ` Rémi Dewitte
2009-02-17 17:14 ` Sylvain Le Gall [this message]
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=slrngpls2s.e8q.sylvain@gallu.homelinux.org \
--to=sylvain@le-gall.net \
--cc=caml-list@inria.fr \
/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