[erlang-questions] performance vs msg queue length

John Erickson jderick@REDACTED
Wed Apr 21 00:25:44 CEST 2010


These results are clearly better, but still I'm a bit surprised there is a
noticable slowdown, especially from 100-10k.  Does anyone know the reason
for this?  It seems to imply we should try to keep message queues under 100
messages.  I also wonder how message size plays into this.


On Tue, Apr 20, 2010 at 12:15 PM, Per Melin <per.melin@REDACTED> wrote:

> On Tue, Apr 20, 2010 at 8:41 PM, John Erickson <jderick@REDACTED> wrote:
> > [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
>
> One little change:
>
> [begin L = lists:seq(1,N),
>      [ self() ! a || _ <- L ],
>      S = now(),
>      [ receive _ -> ok end || _ <- L ],
>       io:format("~w~n", [timer:now_diff(now(), S) / N])
> end || N <- [1,10,100,1000,10000,100000,1000000]].
>
> 1.0
> 0.1
> 0.06
> 0.091
> 0.1144
> 0.11898
> 0.120905
>


More information about the erlang-questions mailing list