Raimo,<br><br>One more question, I have a running system, and a shell is open, how to profile the whole system using fprof?<br><br>I tried the following without luck,<br><br>(<a href="mailto:incomingproxy@ibm.goodstart.org">incomingproxy@ibm.goodstart.org</a>)1> fprof:start().<br>
{ok,<0.150.0>}<br>(<a href="mailto:incomingproxy@ibm.goodstart.org">incomingproxy@ibm.goodstart.org</a>)2> fprof:trace(start, "fprof.trace").<br>ok<br>(<a href="mailto:incomingproxy@ibm.goodstart.org">incomingproxy@ibm.goodstart.org</a>)3> <br>
=PROGRESS REPORT==== 28-Jan-2009::21:16:37 ===<br> supervisor: {local,inet_gethost_native_sup}<br> started: [{pid,<0.159.0>},{mfa,{inet_gethost_native,init,[[]]}}]<br><br>=PROGRESS REPORT==== 28-Jan-2009::21:16:37 ===<br>
supervisor: {local,kernel_safe_sup}<br> started: [{pid,<0.158.0>},<br> {name,inet_gethost_native_sup},<br> {mfa,{inet_gethost_native,start_link,[]}},<br>
{restart_type,temporary},<br> {shutdown,1000},<br> {child_type,worker}]<br><br>(<a href="mailto:incomingproxy@ibm.goodstart.org">incomingproxy@ibm.goodstart.org</a>)3> fprof:trace(stop). <br>
ok<br>(<a href="mailto:incomingproxy@ibm.goodstart.org">incomingproxy@ibm.goodstart.org</a>)4> fprof:analyse(). <br>{error,no_profile}<br><br>The manual and documentation on fprof does not show the example on this scenario. Can you point out what I did wrong?<br>
<br>Thanks for help,<br><br>kaiduan<br><br><br><div class="gmail_quote">On Wed, Jan 28, 2009 at 12:55 PM, Kaiduan Xie <span dir="ltr"><<a href="mailto:kaiduanx@gmail.com">kaiduanx@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Thanks a lot, Raimo for the help.<br><br>More questions,<br><br>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.)<br>
<br>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.<br><br>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.<br>
<br>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? <br><br>Thanks,<br><font color="#888888"><br>
kaiduan</font><div><div></div><div class="Wj3C7c"><br><br><div class="gmail_quote">
On Wed, Jan 28, 2009 at 3:17 AM, Raimo Niskanen <span dir="ltr"><<a href="mailto:raimo%2Berlang-questions@erix.ericsson.se" target="_blank">raimo+erlang-questions@erix.ericsson.se</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div>On Tue, Jan 27, 2009 at 11:00:10PM -0500, Kaiduan Xie wrote:<br>
> Hi, all,<br>
><br>
> I have a question on how to find the hot spot of large base Erlang system.<br>
> For example, after running cprof.start(), cprof.pause(), cprof.analyze(), I<br>
> got the following results (only the first item is listed below),<br>
><br>
> {1847012003,<br>
> [{io_lib_format,722457356,<br>
> [{{io_lib_format,pcount,2},109483111},<br>
> {{io_lib_format,collect,2},109483111},<br>
> {{io_lib_format,build,3},109483111},<br>
> {{io_lib_format,iolist_to_chars,1},83312743},<br>
> {{io_lib_format,indentation,2},60014886},<br>
> {{io_lib_format,field_value,2},26618934},<br>
> {{io_lib_format,field_value,3},17824836},<br>
> {{io_lib_format,precision,2},17706522},<br>
> {{io_lib_format,pad_char,2},17706522},<br>
> {{io_lib_format,field_width,3},17706522},<br>
> {{io_lib_format,field_width,2},17706522},<br>
> {{io_lib_format,decr_pc,2},17706522},<br>
> {{io_lib_format,control,7},17706522},<br>
> {{io_lib_format,collect_cseq,2},17706522},<br>
> {{io_lib_format,collect_cc,2},17706522},<br>
> {{io_lib_format,print,7},14402937},<br>
> {{io_lib_format,chars,2},8912422},<br>
> {{io_lib_format,term,5},8912417},<br>
> {{io_lib_format,min|...},8912416},<br>
> {{io_lib_format|...},8912416},<br>
> {{...}|...},<br>
> {...}|...]},<br>
><br>
> So here comes the question, how can we find which part calls<br>
> (io_lib_format,pcount,2) most? I tried to use fprof(), but it seems that you<br>
> need to know the arguments of the function first.<br>
><br>
> What is the best practice to address this problem? Or did I do something<br>
> wrong?<br>
<br>
</div></div>No, you are on track. This is the curse of cprof - it only gives you<br>
the call count but with minimal strain on your system. The curse of<br>
fprof is that it gives you lots of information for the price of<br>
a very high system load.<br>
<br>
Now you can read some code. The module io_lib_format is an internal<br>
module for io_lib and io. So the user code calls either io:format/1,2,3,<br>
io:fwrite/1,2,3, io_lib:format/2 or io_lib:fwrite/2. You can search<br>
for those in your source and see which are suspicious.<br>
<br>
You can also hand craft a trace by tracing only the io and io_lib functions<br>
in the previous paragraph using the match spec function {caller}.<br>
This you might do with the dbg module, maybe some other trace tool,<br>
or write one yourself. That would give you an idea of who is to blame.<br>
<br>
><br>
> Thanks,<br>
><br>
> kaiduan<br>
<br>
> _______________________________________________<br>
> erlang-questions mailing list<br>
> <a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
> <a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>
<font color="#888888"><br>
--<br>
<br>
/ Raimo Niskanen, Erlang/OTP, Ericsson AB<br>
</font></blockquote></div><br>
</div></div></blockquote></div><br>