Existing methods for call graph profiling, such as that used by gprof, deal badly with programs that have shared subroutines, mutual recursion, higher‐order functions, or dynamic method binding. This article discusses a way of improving the accuracy of a call graph profile by collecting more information during execution, without significantly increasing the overhead of profiling. The method is based on keeping track of a context, consisting of the set of subroutines that are active at a particular moment during execution, together with the calling arcs between these subroutines. The profiler records the time spent in each context during execution of the program, and thus obtains an accurate measurement of the total time during which each subroutine was active. By recording arc information for only the most recent activation of each subroutine, it is possible to arrange that even recursive programs give rise to a finite number of these contexts, and in typical real programs, the number of distinct contexts remains manageably small. The data can be collected efficiently during execution by constructing a finite‐state machine whose states correspond to contexts, so that when a context is entered for a second or subsequent time, only a single access of a hash table is needed to update the state of the profiling monitor. Copyright © 2003 John Wiley & Sons, Ltd.
[1]
J. Larus.
Whole program paths
,
1999,
PLDI '99.
[2]
Stephen A. Jarvis,et al.
Profiling Large-Scale Lazy Functional Programs
,
1996,
J. Funct. Program..
[3]
Susan L. Graham,et al.
An execution profiler for modular programs
,
1983,
Softw. Pract. Exp..
[4]
Simon L. Peyton Jones,et al.
Formally based profiling for higher-order functional languages
,
1997,
TOPL.
[5]
James R. Larus,et al.
Efficient path profiling
,
1996,
Proceedings of the 29th Annual IEEE/ACM International Symposium on Microarchitecture. MICRO 29.
[6]
Niklaus Wirth,et al.
Programming in Oberon - steps beyond Pascal and Modula
,
1992
.
[7]
Susan L. Graham,et al.
Gprof: A call graph execution profiler
,
1982,
SIGPLAN '82.
[8]
Carl Ponder,et al.
Inaccuracies in program profilers
,
1988,
Softw. Pract. Exp..
[9]
Prof. Dr. Hanspeter Mössenböck.
Object-Oriented Programming in Oberon-2
,
1995,
Springer Berlin Heidelberg.
[10]
W. E. Weihl,et al.
Efficient and flexible value sampling
,
2000,
SIGP.
[11]
J. Michael Spivey,et al.
An introduction to logic programming through Prolog
,
1996,
Prentice Hall International series in computer science.
[12]
James R. Larus,et al.
Exploiting hardware performance counters with flow and context sensitive profiling
,
1997,
PLDI '97.