views:

122

answers:

1

Yesterday I was reading about debugging techniques and found Valgrind to be really interesting. It seems to use techniques from dynamic code analysis. And I followed a link from the original reference to something else called Path Profiling.

I tried Googling but I guess I am using the wrong terms to search for a good reference on these concepts. Can someone suggest a good resource taking into account that I do not have a background in compilers and programming languages?

+3  A: 

Path Profiling is interesting as a theoretical problem. gprof is also interesting, because it deals in call graphs, cyclical subgraphs, and such. There are nice algorithms for manipulating this information and propogating measurements throughout a structure.

All of which might tempt you to think it works (though they never say it does) - for finding general performance problems.

However, suppose your program hangs. How do you find the problem?

What I do is get it into the infinite loop, and then interrupt (pause) it to see what it's doing. I look at the code on each level of the call stack, because I know the loop is somewhere on the stack. If it's not obvious, I just step it along until I see it repeating itself, and then I know where the problem is. I suspect almost anyone would do that.

In fact, if you stop the program while it's taking too long and examine its state several times, you can not only find infinite loops, but almost any problem where the program runs longer than you would like.

There are profiler tools based on this concept, such as Zoom and LTProf, but for my money nothing gives as much insight as thoroughly understanding representative snapshots.

You won't find good references on this technique because (oddly) not many people are aware of it, and it's too simple to publish.

There's considerably more to say on the subject.


Actually, FWIW, I "published" an article on it, but it was only reviewed by an editor, and I don't think anyone's actually read it: Dunlavey, “Performance tuning with instruction-level cost derived from call-stack sampling”, ACM SIGPLAN Notices 42, 8 (August, 2007), pp. 4-8.

Mike Dunlavey
+1 for simple solutions the academics hate. :-) Actually, one of the biggest benefits of your approach is that it does not suffer from changes in performance due to observation.
R..
@R..: I was an academic, and I enjoyed teaching, but I could see that academia is an echo chamber, largely insulated from the real-world input that could steer their thinking in more useful directions.
Mike Dunlavey
@Mike: +1 for your time and explanation. Very nice in fact. I'm currently traveling so don't have access to ACM. Will read the paper when I get back to work. I really like the bold statement you made: "too simple to publish" :)
Legend