[erlang-questions] Percept2 and gen_server messages

H.Li@REDACTED H.Li@REDACTED
Sun Jan 19 22:22:35 CET 2014


Hi Tyron,

Percept2 monitors both types of communications (via explicit message
passing and the gen_server:call/2). The reason that you got only one
message send/receive is that the 'start_link' function you profiled
returned immediately after the gen_server has been started, so the process
you saw was the process that started the gen_server process, not the
gen_server process itself.

Kind Regards,
Huiqing

> Hi all,
>
>     I am trying to use Percept2 to find out the communication overhead of
> a
> gen_server process. However, when I'm analyzing the "*.dat" generated I'm
> only finding the following for my gen_server process (code below):
> msgs_recv = 1
> avg_size_msgs_recv = 18
> msgs_sent = 1
> avg_size_msgs_sent = 72
>
> We are communicating with this server both via messages (ServerPid !
> {test}) and the gen_server:call/2
>
> Are we missing something here? Shouldn't the request/ replies be recorded
> as msgs?
>
>
>
>
>
>
>
>
> %%  gen_server code
> -module(test_percept_1).
>
> -behaviour(gen_server).
>
> -define(SERVER, ?MODULE).
>
> -export([
> init/1,
> handle_call/3,
> start_link/0,
> handle_info/2 ,
>         .....
> ]).
>
> start_profiling() ->
> percept2:profile("data.dat", {test_percept_1,start_link, []},[all]).
> stop_profiling() ->
> percept2:stop().
> start_link() ->
> case gen_server:start_link({local, ?SERVER}, ?SERVER, [], []) of
> {ok, Pid} ->
> io:format("Gen_server started: ~p on node: ~p. ~n",[Pid,node()]),
> {ok,Pid};
> Other ->
> io:format("Error starting ~p: ~p. ~n",[?SERVER,Other]),
> {error, Other}
>     end.
> init([]) -> {ok,[]}.
>
> ....
>
> handle_call({test},_From,State)->
> {reply,"This is a test string",State}.
>
> .....
> handle_info(_, State) ->
> {noreply,state}.
>
> .....
>
>
>
> --
> Best Regards,
> Tyron Zerafa
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>





More information about the erlang-questions mailing list