[erlang-questions] Process spawn time with -smp

lang er <>
Mon Apr 9 06:09:31 CEST 2007


I retest the code with different number of scheduler threads , the
result prove your explanation:

erl -smp -noshell +P 1000000 -s processes max 800000 -s init stop +S 1
Maximum allowed processes:1000000
Process spawn time=7.21250 (10.6738) microseconds

erl -smp -noshell +P 1000000 -s processes max 800000 -s init stop +S 2
Maximum allowed processes:1000000
Process spawn time=20.9750 (24.7775) microseconds

erl -smp -noshell +P 1000000 -s processes max 800000 -s init stop +S 3
Maximum allowed processes:1000000
Process spawn time=35.3875 (55.7313) microseconds

BTW, Are there any good documents/papers about Erlang VM's internals?

Thanks!
BR
James


On 09/04/07, Rickard Green <> wrote:
> Hi!
>
> This test program isn't especially nice to the smp emulator. When a
> process is placed in the run-queue, scheduled in, or scheduled out, a
> lock on the run-queue has to be held. When a child processes in this
> program has been spawned, it is put in the run-queue, later scheduled
> in, and then immediately scheduled out. Since the test will make sure
> that there will be plenty of processes in the run-queue, all scheduler
> threads available will be woken. Since the child processes doesn't do
> anything, the scheduler threads will more or less only fight about the
> run-queue lock.
>
> I ran the test program myself on a couple of our machines, but I didn't
> get as bad figures as you got. The worst I got was a little more than
> twice the time for the smp emulator compared to the non-smp emulator on
> a machine with four cores. When I ran the smp emulator with only one
> scheduler thread on that same machine I got times 5-30% longer than for
> the non-smp emulator. This comparison is more interesting since there
> will not be such a fight about the run-queue lock, as described above,
> when processes actually do something.
>
> BR,
> Rickard Green, Erlang/OTP, Ericsson AB.
>
> lang er wrote:
> > Hi!
> > I run code from Joe's new book on my macbook(2G RAM and  2GHz Intel
> > Core Duo CPU) to test how fast erlang create processes.
> >
> > I compile Erlang with smp support, and I test with smp flag on and off.
> >
> > The following is the results :
> >
> > erl -noshell +P 1000000 -s processes max 800000 -s init stop
> > Maximum allowed processes:1000000
> > Process spawn time=4.16250 (8.02000) microseconds
> >
> > erl -smp -noshell +P 1000000 -s processes max 800000 -s init stop
> > Maximum allowed processes:1000000
> > Process spawn time=19.7000 (28.0012) microseconds
> >
> > So  why process spawn is so slow with smp?
> >
> > -------------
> > test code from joe's book:
> >
> > max(N) ->
> >    Max = erlang:system_info(process_limit),
> >    io:format("Maximum allowed processes:~p~n" ,[Max]),
> >    statistics(runtime),
> >    statistics(wall_clock),
> >    L = for(1, N, fun() -> spawn(fun() -> wait() end) end),
> >   {_, Time1} = statistics(runtime),
> >   {_, Time2} = statistics(wall_clock),
> >   lists:foreach(fun(Pid) -> Pid ! die end, L),
> >   U1 = Time1 * 1000 / N,
> >   U2 = Time2 * 1000 / N,
> >   io:format("Process spawn time=~p (~p) microseconds" ,
> >   [U1, U2]).
> >
> > wait() ->
> >   receive
> >    die -> void
> >  end.
> >  for(N, N, F) -> [F()];
> >  for(I, N, F) -> [F()|for(I+1, N, F)].
> >
> >
> >
> > BR!
> > James
> > _______________________________________________
> > erlang-questions mailing list
> > 
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> >
>



More information about the erlang-questions mailing list