[erlang-questions] performance vs msg queue length
John Erickson
jderick@REDACTED
Tue Apr 20 20:41:47 CEST 2010
Good to know about mnesia and gen_server doing selective receives, but I am
not using either. BTW, I found some other evidence of this slowdown from an
earlier posting. Although the main post was about interpreter speed, I
found these benchmark numbers quite strange for the compiled version as
well. With message queues of 10k, it looks like about 3x slowdown.
[begin [ self() ! a || _ <- lists:seq(1,N) ],
> S = now(),
> [ receive _ -> ok end || _ <- lists:seq(1,N) ],
> io:format("~w~n", [timer:now_diff(now(), S) / N])
> end || N <- [1,10,100,1000,10000]].
>
> ...
>
> If I put it into a module, add 1e5 and 1e6 then I get:
>
> 1> test:test().
> 1.0
> 0.1
> 0.06
> 0.114
> 0.1554
> 0.36398
> 0.358997
>
On Tue, Apr 20, 2010 at 8:00 AM, David Mercer <dmercer@REDACTED> wrote:
> On Tuesday, April 20, 2010, Ulf Wiger wrote:
>
> > One of the things being debated is how much rope should be given
> > to the programmers, that they may hang themselves with. One great
> > advantage of having the compiler do it internally is that it
> > would only do so if in cases where it is absolutely safe to do
> > so.
> >
> > I think the pattern would work in most, but not necessarily all,
> > of the places where selective receive is required. For the
> > remaining cases, I'm not convinced - off the top of my head -
> > that an explicit mark_queue() function would help either
> > (but that's from spending 10 seconds thinking about it, so I
> > may well be wrong.)
>
> Unfortunately, my spot-check of about 30 selective receives within the OTP
> library indicates that a receive after an erlang:monitor is the exception
> rather than the rule. I may have just been unlucky, and I'm sure ROK could
> put his code-scanner to work to tell us exactly how often it occurs.
>
> Cheers,
>
> DBM
>
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>
>
More information about the erlang-questions
mailing list