2

I'm working on a complex network software and I have trouble determining how to improve the systems performance.

Specifically in one part of the software which is using blocking synchronous calls. Since this part of the system is doing heavy computations it's nearly impossible to determine whether the slowness of this component is caused by these computations or the waiting for the other parts of the system.

Are there any light-weight profilers that can capture this information? I can't use heavy duty profile like valgrind since that would completely skew the results (although valgrind would be perfect, since it captures all the required information).

I tried using oProfile but I just wasn't able to get any meaningful results out of it (perhaps if there is a concise tutorial somewhere...).

Šimon Tóth
  • 35,456
  • 20
  • 106
  • 151
  • I would give oprofile one more go, google "oprofile tutorial" to see if you find anything that matches your need – Fredrik Pihl Jun 07 '11 at 10:45
  • @Fredrik The thing is that I was able to run oprofile using those tutorials, but I just couldn't get any meaningful info out of it. And that is something that is not covered by the tutorials, they usually end with the "now we have the results". – Šimon Tóth Jun 07 '11 at 10:48
  • 2
    `ltrace` and `strace` can be hugely helpful in getting a good idea where does the code spend its time, especially with the -c switch (overview/summary) and -e switches(digging into details). – Marcin Jun 07 '11 at 11:03
  • @William Pursell gprof only captures user time – Šimon Tóth Jun 07 '11 at 12:21
  • @Let_Me_Be Perhaps I don't understand the problem. If you need to know how much time is spent in a system call, put a wrapper around it and gprof will tell you time spent in the wrapper. Refactoring the code for increased modularity is usually adequate for getting gprof to tell you what want. – William Pursell Jun 07 '11 at 12:50
  • @William Pursell No it won't. Try a function with a single sleep and gprof will tell you that you spent 0% in the function, even if the sleep was 99,99% of the program run time. – Šimon Tóth Jun 07 '11 at 12:52
  • @William: *gprof* is blind to any sort of blocked time, like I/O, because it only samples while the user's program has the program counter. – Mike Dunlavey Jun 07 '11 at 15:27

3 Answers3

1

What you need is something that gives you stack samples, on wall-clock time (not just CPU time like gprof), and reports by line (not just by function) the percent of samples containing the line.

Zoom will do it, but I just do random-pausing. Here's why it works. Here's a blow-by-blow example. Here's another explanation.

Community
  • 1
  • 1
Mike Dunlavey
  • 40,059
  • 14
  • 91
  • 135
0

Comment out your "heavy computations" and see if it's still slow. That will tell you if it's waiting on other systems over the network or the computations. The answer may not be either/or and may just be an accumulation of things.

Jay
  • 13,803
  • 4
  • 42
  • 69
  • You can't just comment out a portion of a working system :-D Without the computations there will be no network communication. – Šimon Tóth Jun 07 '11 at 14:20
0

You could also do some old fashioned printf debugging and print the time before and after executing the function to standard output or syslog. That is about as light-weight as profiling gets.

waffleman
  • 4,159
  • 10
  • 39
  • 63