From: Yaron Minsky <yminsky@gmail.com>
To: Cedric Cellier <rixed@happyleptic.org>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] [ANN] Async, a monadic concurrency library
Date: Wed, 26 Oct 2011 06:40:37 -0400 [thread overview]
Message-ID: <CADKNfhJHEj3Sdw5Fo+R+dr7Sc8acXaiCLpYBOSpgnquXC8+iCg@mail.gmail.com> (raw)
In-Reply-To: <1319607060.20523.11.camel@Nokia-N900>
[-- Attachment #1: Type: text/plain, Size: 2169 bytes --]
On Wed, Oct 26, 2011 at 1:31 AM, Cedric Cellier <rixed@happyleptic.org>wrote:
> While comparing async and lwt you forget to mention performances. Didn't
> you run any benchmark with some result to share ? Or are Async performances
> irrelevant to your use cases so you never benchmarked ?
Perhaps surprisingly, while we've benchmarked and tuned the performance of
Async, but we've never done the same for Lwt.
This has to do with history as much as anything else. We wrote the first
version of Async years ago, when Lwt was much less mature. We looked at Lwt
at the time and decided that there were several design choices that made it
unsuitable for our purposes, so we wrote Async. We've looked back at Lwt
for inspiration over the years, but we've never again had the question in
front of us as to whether to use Lwt or Async, so doing the benchmarking has
never been high on our list.
We do have some guesses about how performance differs. For example, Lwt's
bind is faster than Async's bind because of different interleaving policies:
Lwt can run the right-hand side of a bind immediately, whereas in Async,
it's always scheduled to run later, so that's more work that Async has to do
in. That said, we prefer the semantics of Async's bind, even though it has
a performance cost. (You can easily implement Lwt-style bind.)
Another thing to note for any intrepid benchmarkers is that the released
version of Async is missing a useful feature that is already available in
our development trunk, which is tail-recursive bind. In the released
version, the following loop:
let rec loop () =
after (sec 30.)
>>= fun () ->
printf ".%!";
loop ()
will allocate an unbounded amount of space, creating one deferred value
every 30 seconds. In our development trunk bind is tail-recursive, but that
hasn't gotten to the public release yet.
You can do the same loop efficiently in Async using the upon operator:
let rec loop () =
after (sec 30.)
>>> fun () ->
printf ".%!";
loop ()
This is actually more efficient than using the tail-recursive version of
bind, since it allocates one less deferred value every time through the
loop.
y
[-- Attachment #2: Type: text/html, Size: 3617 bytes --]
next prev parent reply other threads:[~2011-10-26 10:40 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-26 0:32 Yaron Minsky
2011-10-26 5:31 ` Cedric Cellier
2011-10-26 10:40 ` Yaron Minsky [this message]
2011-10-26 7:33 ` Gerd Stolpmann
2011-10-26 10:57 ` Yaron Minsky
2011-10-26 11:18 ` rixed
2011-10-26 11:34 ` Yaron Minsky
2011-10-26 12:49 ` Jérémie Dimino
2011-10-26 12:31 ` Gerd Stolpmann
2011-10-27 17:36 ` Milan Stanojević
2011-10-27 18:34 ` Gerd Stolpmann
2011-10-27 19:10 ` Milan Stanojević
2011-10-28 7:29 ` Gerd Stolpmann
2011-10-26 8:07 ` Jérémie Dimino
2011-10-26 11:03 ` Yaron Minsky
2011-10-26 11:06 ` Mark Shinwell
2011-10-26 11:20 ` Anil Madhavapeddy
2011-10-26 11:37 ` Mark Shinwell
2011-10-29 0:52 ` oliver
2011-10-31 9:12 ` Mark Shinwell
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=CADKNfhJHEj3Sdw5Fo+R+dr7Sc8acXaiCLpYBOSpgnquXC8+iCg@mail.gmail.com \
--to=yminsky@gmail.com \
--cc=caml-list@inria.fr \
--cc=rixed@happyleptic.org \
/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