Coro benchmarks ?

Marc Lehmann schmorp at schmorp.de
Sat Apr 30 06:20:42 CEST 2011


On Fri, Apr 29, 2011 at 09:53:42PM +0200, Przemyslaw Iskra <sparky at pld-linux.org> wrote:
> Are there some good benchmarks for coro to test how blocking is some
> thread / module / whatever ?

If you ever find a method on how to benchmark some API without knowing it
let us know :)

> I am developing a libcurl wrapper (which is designed to be non-blocking)
> and I want the best integration with Coro I could achieve.

In most cases, and especially when the underlying library is reasonably
event-like (as libcurl is), then I would recommend keeping it event-based and
base it on AnyEvent - that will automatically make it compatible to Coro, and
usually quite efficiently so.

If you want to make it utmost efficient, you can always add, say, an XS
interface to EV with fallback to plain AE.

But using AE (I mean the AE:: namespace, not AnyEvent) on the perl level
will already gie you the highets speed possible.

AnyEvent will give your module the widest possible audience, much better
than Coro, and will fit into Coro automatically.

> object for all requests, running under EV or AnyEvent, and it will use
> Coro::Semaphore or AE::cv to simulate blocking requests.

Again, AE::cv is preferable - when used with Coro it will have comparable
performance to a Coro::Signal, but has no dependency on Coro.

Now, with regrds to curl - last I looked, the libcurl interface basically
forces you to use select, as it doesn't tell you about fd lifetimes, so
using it with a stateful backend such as kqueue or epoll will suck (you
have tod estroy and recreate all watchers in each iteration). The existing
Curl perl interface modules don't even give you a timeout or anything, so
you more or less will have to write your own.

OTOH, there already is AnyEvent::Curl and AnyEvent::Curl::Multi - maybe
improving WWW::Curl to add timeout functionality and then improving that
might be the better way.

Of course, having 4+ curl modules on cpan isn't necessarily bad.

> fair benchmark

Well, Coro::LWP shouldn't be the target for that, as it solves different
problems - AnyEvent::HTTP is a much more sensible target for benchmarks -
but it will almost cetrainly be slower, the question is just by how much.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\



More information about the anyevent mailing list