[Shootout-list] Re: ring of processes
Brent Fulgham
bfulg@pacbell.net
Sat, 02 Oct 2004 19:49:38 -0700
On 2004-10-02 18:56:40 -0700 Aaron Denney <wnoise@ofb.net> wrote:
> And here it is. Surprisingly to me, -O2 yields a _significant_
> speedup,
> as did the switch to MVars.
>
> It's now roughly one-third of a second per iteration,
It's interesting that the performance is still quite bad, even using
MVars.
If you compare the relative cost of firing off processes in Erlang
versus using
MVars (see http://shootout.alioth.debian.org/bench/procinst/), you can
see that MVars are *very* lightweight, costing virtually nothing in
CPU or
Memory. Erlang's processes cost much more (in terms of memory) but are
almost as cheap to build in CPU time.
However, it seems that the message passing behavior of the two is
widely
divergent.
One obvious difference is that the Erlang tests are using atoms as the
messages
they pass around, with a final "atom_to_string" to make something we
can print.
The Haskell version uses strings, which may be more costly to send and
process.
Does anyone know if this might be playing a part?
If you look at http://shootout.alioth.debian.org/bench/ringmsg/, you
can see that
the Haskell implementation is burning a lot of cycles doing
*something*.
-Brent