Optimally profiling and tracing programs

This paper presents algorithms for inserting monitoring code to profile and trace programs. These algorithms greatly reduce the cost of measuring programs. Profiling counts the number of times each basic block in a program executes and has a variety of applications. Instruction traces are the basis for trace-driven simulation and analysis, and are also used in trace-driven debugging. The profiling algorithm chooses a placement of counters that is optimized—and frequently optimal—with respect to the expected or measured execution frequency of each basic block and branch in the program. The tracing algorithm instruments a program to obtain a subsequence of the basic block trace—whose length is optimized with respect to the program's execution—from which the entire trace can be efficiently regenerated. Both algorithms have been implemented and produce a substantial improvement over previous approaches. The profiling algorithm reduces the number of counters by a factor of two and the number of counter increments by up to a factor of four. The tracing algorithm reduces the file size and overhead of an already highly optimized tracing system by 20-40%.

[1]  W. G. Morris,et al.  CCG: a prototype coagulating code generator , 1991, PLDI '91.

[2]  Robert L. Probert,et al.  Optimal Insertion of Software Probes in Well-Delimited Programs , 1982, IEEE Transactions on Software Engineering.

[3]  Brian W. Kernighan,et al.  The C Programming Language , 1978 .

[4]  David R. Ditzel,et al.  An analysis of MIPS and SPARC instruction set utilization on the SPEC benchmarks , 1991, ASPLOS IV.

[5]  David S. Johnson,et al.  Computers and Intractability: A Guide to the Theory of NP-Completeness , 1978 .

[6]  James R. Larus,et al.  Abstract execution: A technique for efficiently tracing programs , 1990, Softw. Pract. Exp..

[7]  Robert E. Tarjan,et al.  Data structures and network algorithms , 1983, CBMS-NSF regional conference series in applied mathematics.

[8]  James R. Larus,et al.  Efficient program tracing , 1993, Computer.

[9]  Ira R. Forman,et al.  On the time overhead of counters and traversal markers , 1981, ICSE '81.

[10]  Shachindra N Maheshwari Traversal Marker Placement Problems Are NP-Complete ; CU-CS-092-76 , 1976 .

[11]  James R. Larus,et al.  Branch prediction for free , 1993, PLDI '93.

[12]  Scott McFarling,et al.  Procedure merging with instruction caches , 1991, PLDI '91.

[13]  Donald E. Knuth,et al.  Optimal measurement points for program frequency counts , 1973 .

[14]  Donald Ervin Knuth,et al.  The Art of Computer Programming , 1968 .

[15]  Marvin H. Solomon,et al.  Optimal code for control structures , 1982, POPL '82.

[16]  Alan Dain Samples,et al.  Profile-Driven Compilation , 1991 .

[17]  Jong-Deok Choi,et al.  A mechanism for efficient debugging of parallel programs , 1988, PADD '88.

[18]  John L. Hennessy,et al.  Mtool: An Integrated System for Performance Debugging Shared Memory Multiprocessor Applications , 1993, IEEE Trans. Parallel Distributed Syst..

[19]  Jong-Deok Choi,et al.  Techniques for debugging parallel programs with flowback analysis , 1991, TOPL.

[20]  Karl Pettis,et al.  Profile guided code positioning , 1990, PLDI '90.

[21]  James R. Larus,et al.  Optimally profiling and tracing programs , 1994, TOPL.

[22]  David W. Wall Predicting program behavior using real or estimated profiles , 1991, PLDI '91.

[23]  N. S. Barnett,et al.  Private communication , 1969 .

[24]  R. V. Helgason,et al.  Algorithms for network programming , 1980 .

[25]  Bjarne Stroustrup,et al.  C++ Programming Language , 1986, IEEE Softw..

[26]  C. V. Ramamoorthy,et al.  Optimal placement of software monitors aiding systematic testing , 1975, IEEE Transactions on Software Engineering.

[27]  Susan L. Graham,et al.  An execution profiler for modular programs , 1983, Softw. Pract. Exp..

[28]  Vivek Sarkar,et al.  Determining average program execution times and their variance , 1989, PLDI '89.

[29]  Alexandru Nicolau,et al.  Parallel processing: a smart compiler and a dumb machine , 1984, SIGP.

[30]  Donald E. Knuth,et al.  The art of computer programming: V.1.: Fundamental algorithms , 1997 .

[31]  Alfred V. Aho,et al.  Compilers: Principles, Techniques, and Tools , 1986, Addison-Wesley series in computer science / World student series edition.