[erlang-questions] beginner: Message Passing Overhead in Erlang

KangMikyung mikyung_kang@REDACTED
Fri Feb 13 21:33:54 CET 2009


Dear All,

When I tested pingpong test, Erlang takes long time even though the data size is 0/1/2/4/8 bytes.

MPI takes around 0.0025 microseconds/iteration when the data size 0/1/2/4/8 bytes.

However Erlang takes around 0.5 microseconds/iteration at least. (within one core)


I tried to find the underlying reasons that there is higher overhead involved in message
passing in Erlang when compared to MPI,
but I couldn't find it yet at "The erlang-questions Archives".

How can we explain the situation that Erlang takes long time even though the data size is very small (e.g. 0 or 1)?
Why the communication overhead is very big? When the data size is 16KB, Erlang was slower than MPI at least thousands time.
Where can I find the explanation?

Also I tested two pingpong case: (1) with data('a') and (2) without data.
(1) takes 0.336 us, but (2) takes 0.0000000059 us. It's very different.
Can we tell initial data related setup takes long time?

Thanks,
Mikyung


(1)
-module(tut15).
-export([run/0]).

-include("imb.hrl").

ping(0, _, _) ->
    done;

ping(R, D, Pong) ->
    Pong ! {self(), D},
    receive
        {Pong, D} ->
    ping(R - 1, D, Pong)
    end.

pong() ->
    receive
        {From, D} -> 
            From ! {self(), D}, 
            pong()
    end.

run() ->
    R = 1000,
    D = 'a', %D = "abcdefghij",
    Pong = spawn(fun()-> pong() end),
  TimeStart = imb:time_microseconds(),
    ping(R, D, Pong),
  TimeEnd = imb:time_microseconds(),
  io:format("Time in microseconds: ~p~n", [TimeEnd - TimeStart]).



(2)
-module(tut15).
-export([start/0, ping/2, pong/0]).

-include("imb.hrl").

ping(0, Pong_PID) ->
    Pong_PID ! finished;

ping(N, Pong_PID)
 ->
    Pong_PID ! {ping, self()},
    receive
        pong ->
        ping(N - 1, Pong_PID)
    end.

pong() ->
    receive
        {ping, Ping_PID} ->
            Ping_PID ! pong,
            pong()
    end.

start() ->
  TimeStart = imb:time_microseconds(),
    Pong_PID = spawn(tut15, pong, []),
   
 spawn(tut15, ping, [1000, Pong_PID]),
  TimeEnd = imb:time_microseconds(),
  io:format("Time in microseconds: ~p~n", [TimeEnd - TimeStart]).


**
time_microseconds() ->
    {MS, S, US} = now(),
    (MS * 1.0e+12) + (S * 1.0e+6) + US.


_________________________________________________________________
강력해진 보안성, 아웃룩을 닮아 편리해진 기능들로 무장한 Windows Live Hotmail! 지금 로그인해 보세요!
http://www.hotmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090213/3637e659/attachment.htm>


More information about the erlang-questions mailing list