Dante
Dante

Reputation: 11264

How to visualize profile files graphically?

I'm developing Go 1.2 on Windows 8.1 64 bit. I had many issues getting the go pprof tool to work properly such as memory addresses being displayed instead of actual function names.

However, i found profile which seems to do a great job at producing profile files, which work with the pprof tool. My guestion is, how do i use those profile files for graphical visualization?

Upvotes: 1

Views: 11482

Answers (2)

Mike Dunlavey
Mike Dunlavey

Reputation: 40669

If your goal is to see pretty but basically meaningless pictures, go for visualization as @Specode suggested.

If your goal is speed, then I recommend you forget visualization. Visualization does not tell you what you need to fix.

This method does tell you what to fix. You can do it quite effectively in GDB.

EDIT in response to @BurntSushi5:

Here are my "gripes with graphs" :)

In the first place, they are super easy to fool. For example, suppose A1 spends all its time calling C2, and vice-versa. Then suppose a new routine B is inserted, such that when A1 calls B, B calls C2, and when A2 calls B, B calls C1. The graph loses the information that every time C2 is called, A1 is above it on the stack, and vice-versa.

enter image description here

For another example, suppose every call to C is from A. Then suppose instead A "dispatches" to a bunch of functions B1, B2, ..., each of which calls C. The graph loses the information that every call to C comes through A.

enter image description here

Now to the graph that was linked:

enter image description here

  • It places great emphasis on self time, making giant boxes, when inclusive time is far more important. (In fact, the whole reason gprof was invented was because self time was about as useful as a clock with only a second-hand.) They could at least have scaled the boxes by inclusive time.

  • It says nothing about the lines of code that the calls come from, or that are spending the self time. It's based on the assumption that all functions should be small. Maybe that's true, and maybe not, but is it a good enough reason for the profile output to be unhelpful?

  • It is chock-full of little boxes that don't matter because their time is insignificant. All they do is take up gobs of real estate and distract you.

  • There's nothing in there about I/O. The profiler from which the graph came apparently embodies that the only I/O is necessary I/O, so there's no need to profile it (even if it takes 90% of the time). In big programs, it's really easy for I/O to be done that isn't really necessary, taking a big fraction of time, and so-called "CPU profilers" have the prejudice that it doesn't even exist.

  • There doesn't seem to be any instance of recursion in that graph, but recursion is common, and useful, and graphs have difficulty displaying it with meaningful measurements.

Just pointing out that, if a small number of stack samples are taken, roughly half of them would look like this:

blah-blah-couldn't-read-it
blah-blah-couldn't-read-it
blah-blah-couldn't-read-it
fragbag.(*structureAtoms).BestStructureFragment
structure.RMSDMem
... a couple other routines

The other half of the samples are doing something else, equally informative. Since each stack sample shows you the lines of code where the calls come from, you're actually being told why the time is being spent. (Activities that don't take much time have very small likelihood of being sampled, which is good, because you don't care about those.)

Now I don't know this code, but the graph gives me a strong suspicion that, like a lot of code I see, the devil's in the data structure.

Upvotes: 1

Specode
Specode

Reputation: 1023

U can try go tool pprof /path/to/program profile.prof to solve function not true problem.

if u want graphical visualization, try input web in pprof.

Upvotes: 2

Related Questions