[erlang-questions] profile question

Kaiduan Xie kaiduanx@REDACTED
Thu Jan 29 04:08:34 CET 2009


Raimo,

One more question, I have a running system, and a shell is open, how to
profile the whole system using fprof?

I tried the following without luck,

(incomingproxy@REDACTED)1> fprof:start().
{ok,<0.150.0>}
(incomingproxy@REDACTED)2> fprof:trace(start, "fprof.trace").
ok
(incomingproxy@REDACTED)3>
=PROGRESS REPORT==== 28-Jan-2009::21:16:37 ===
          supervisor: {local,inet_gethost_native_sup}
             started:
[{pid,<0.159.0>},{mfa,{inet_gethost_native,init,[[]]}}]

=PROGRESS REPORT==== 28-Jan-2009::21:16:37 ===
          supervisor: {local,kernel_safe_sup}
             started: [{pid,<0.158.0>},
                       {name,inet_gethost_native_sup},
                       {mfa,{inet_gethost_native,start_link,[]}},
                       {restart_type,temporary},
                       {shutdown,1000},
                       {child_type,worker}]

(incomingproxy@REDACTED)3> fprof:trace(stop).
ok
(incomingproxy@REDACTED)4> fprof:analyse().
{error,no_profile}

The manual and documentation on fprof does not show the example on this
scenario. Can you point out what I did wrong?

Thanks for help,

kaiduan


On Wed, Jan 28, 2009 at 12:55 PM, Kaiduan Xie <kaiduanx@REDACTED> wrote:

> Thanks a lot, Raimo for the help.
>
> More questions,
>
> 1. From my understanding, Erlang trace is not targeted to find performance
> bottleneck, it is used to help you understand how function is executed. I
> can not figure out how to use trace to find which function calls the
> io_lib_format:pcount in my case most. (In my case, io_lib:format is
> dispersed in the code almost everywhere.)
>
> 2. For fprof, how to profile a function without specifying the arguments?
> For example, I want to fprof io_lib:format, but I want to profile all calls
> on io_lib:format regardless of the real arguments.
>
> 3. In C, we can use gprof to achieve what I want in 2). Although gprof
> increases the system load substantially. What is the counter-part of gprof
> in Erlang.
>
> 4. What is the tool you guys in Ericsson use to profile a high-load system
> without degrading the performance dramatically, at the same time, we can
> still get gprof like output?
>
> Thanks,
>
> kaiduan
>
>
> On Wed, Jan 28, 2009 at 3:17 AM, Raimo Niskanen <
> raimo+erlang-questions@REDACTED<raimo%2Berlang-questions@REDACTED>
> > wrote:
>
>> On Tue, Jan 27, 2009 at 11:00:10PM -0500, Kaiduan Xie wrote:
>> > Hi, all,
>> >
>> > I have a question on how to find the hot spot of large base Erlang
>> system.
>> > For example, after running cprof.start(), cprof.pause(),
>> cprof.analyze(), I
>> > got the following results (only the first item is listed below),
>> >
>> > {1847012003,
>> >  [{io_lib_format,722457356,
>> >                  [{{io_lib_format,pcount,2},109483111},
>> >                   {{io_lib_format,collect,2},109483111},
>> >                   {{io_lib_format,build,3},109483111},
>> >                   {{io_lib_format,iolist_to_chars,1},83312743},
>> >                   {{io_lib_format,indentation,2},60014886},
>> >                   {{io_lib_format,field_value,2},26618934},
>> >                   {{io_lib_format,field_value,3},17824836},
>> >                   {{io_lib_format,precision,2},17706522},
>> >                   {{io_lib_format,pad_char,2},17706522},
>> >                   {{io_lib_format,field_width,3},17706522},
>> >                   {{io_lib_format,field_width,2},17706522},
>> >                   {{io_lib_format,decr_pc,2},17706522},
>> >                   {{io_lib_format,control,7},17706522},
>> >                   {{io_lib_format,collect_cseq,2},17706522},
>> >                   {{io_lib_format,collect_cc,2},17706522},
>> >                   {{io_lib_format,print,7},14402937},
>> >                   {{io_lib_format,chars,2},8912422},
>> >                   {{io_lib_format,term,5},8912417},
>> >                   {{io_lib_format,min|...},8912416},
>> >                   {{io_lib_format|...},8912416},
>> >                   {{...}|...},
>> >                   {...}|...]},
>> >
>> > So here comes the question, how can we find which part calls
>> > (io_lib_format,pcount,2) most? I tried to use fprof(), but it seems that
>> you
>> > need to know the arguments of the function first.
>> >
>> > What is the best practice to address this problem? Or did I do something
>> > wrong?
>>
>> No, you are on track. This is the curse of cprof - it only gives you
>> the call count but with minimal strain on your system. The curse of
>> fprof is that it gives you lots of information for the price of
>> a very high system load.
>>
>> Now you can read some code. The module io_lib_format is an internal
>> module for io_lib and io. So the user code calls either io:format/1,2,3,
>> io:fwrite/1,2,3, io_lib:format/2 or io_lib:fwrite/2. You can search
>> for those in your source and see which are suspicious.
>>
>> You can also hand craft a trace by tracing only the io and io_lib
>> functions
>> in the previous paragraph using the match spec function {caller}.
>> This you might do with the dbg module, maybe some other trace tool,
>> or write one yourself. That would give you an idea of who is to blame.
>>
>> >
>> > Thanks,
>> >
>> > kaiduan
>>
>> > _______________________________________________
>> > erlang-questions mailing list
>> > erlang-questions@REDACTED
>> > http://www.erlang.org/mailman/listinfo/erlang-questions
>>
>> --
>>
>> / Raimo Niskanen, Erlang/OTP, Ericsson AB
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090128/dad719d9/attachment.htm>


More information about the erlang-questions mailing list