[erlang-questions] Process spawn time with -smp

lang er <>
Sun Apr 8 12:02:54 CEST 2007


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



More information about the erlang-questions mailing list