210 likes | 450 Views
Efficient Path Profiling Thomas Ball James R. Larus. 2005. Dec. 6 Chihun Kim. Contents. Introduction Limitation of edge profiling Algorithm of efficient path profiling Basic idea Compactly representing paths with unique integer Finding instrumentation point Placing instrumentations
E N D
Efficient Path ProfilingThomas Ball James R. Larus 2005. Dec. 6 Chihun Kim
Contents • Introduction • Limitation of edge profiling • Algorithm of efficient path profiling • Basic idea • Compactly representing paths with unique integer • Finding instrumentation point • Placing instrumentations • Regenerating path from the profile result • Transforming general CFG to acyclic DAG • Experiment
Introduction • This paper describes a new path profiling algorithm • Simple • Fast • Minimized run-time overhead • Efficient edge profiling : average overhead 16% • Efficient path profiling : average overhead 31%
Limitation of edge profiling • Problems • Edge profiling does not identify the most frequently executed paths • Example : 2 possible results from 1 edge profiling • We need a Path Profiling
Basic idea • Paths are identified by unique integer (path identifier) • Transitions in control flow graph changes the path identifier • Control flow graph acts as State Machine • In the final state, instrumentation code update the number of a path execution • This integer is used to index an array of counter • We need to represent these integers very compactly, because sparse set of identifiers wastes of memory storage
Basic idea • Places instrumentation so that • Transitions of path identifier need not occur at every branches • Basic algorithm assumes that control flow graph is DAG (Directly Acyclic Graph) • We need to transform general CFG to DAG
Compactly representing paths with sum • The first step is to assign a constant value to each edge • Path identifier is a sum of edge values through the path • All path have a unique identifier • Example : edge (ABCDEF) = (2+0+0+1+0) = (3)
Compactly representing paths with sum • What is a edge value? All path strings prefixed with KB are numbered with (0 ~ X-1) K All path strings prefixed with KA are numbered with (X ~ X+Y-1) 0 Number of path from K to exit is (X+Y) X A B Y X = Number of path from B to exit exit
A 0 A A 2 A 2 A A 0 A 0 A 0 A 0 A 0 A 1 A 1 B 1 C 1 ACD : 0 1 1 1 0 0 0 0 0 0 0 B C ABD : 1 B 1 B 0 B 1 B 0 B 0 B B 1 B 1 B 0 B 1 C 1 C 1 C 0 C 1 C 1 C 1 C 0 C 1 C C 1 A B C D D 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 D D 1 D 1 D 1 D 1 D 1 D 1 D 1 D 1 D 1 D 1 Compactly representing paths with sum • Algorithm
Finding instrumentation point • Uses the techniques in the paper • Thomas Ball. Efficiently counting program events with support for on-line queries, ACM Transactions on Programming Languages and Systems, Sep 1994 • Path identifier is preserved, but • Transition events in the paths are reduced • Example: • transition number changes from 3 to 2 in the path (ABDEF)
r = 0 r += 2 r += 4 r += 1 table[ r ] ++ Inserting Instrumentation • Initialize a register for path identifier r in entry node • Update register r in the edge by the edge values • Increment a table in the exit node • The value in register r is used to index the result table
r = 0 r += 2 r += 4 r += 1 table[ r ] ++ Inserting Instrumentation • There are some optimization in updating path register r • You can combine initialization of r and the first update of r • You can combine table update and the final update of r
Regenerating path from the profile result • Given information • R = path identifier • v = current block (initialized to entry block) • e = outgoing edge from the vertex v to w • Val(e) = edge value of the edge e • At each block, find e (v→w) , which is outgoing edge of v with the largest Val(e) ≤ R.
R=4 A 2 B C 2 D 1 E F Regenerating path from the profile result • Example: path register is 4 • Current node is A • You choose edge (A→B) • Because (A→B) has the largest edge value which is smaller than the current path register value 4.
A 2 R=2 B C 2 D 1 E F Regenerating path from the profile result • Example: path register is 4 • Current node is B • Path register is decreased by 2 • Because you choose the edge (A→B) • The second edge is (B→D)
A 2 B C 2 D R=0 1 E F Regenerating path from the profile result • Example: path register is 4 • Current node is D • You cannot select a edge (D→E) • Because a current path register is only 0 • The final edge is (D→F) • Edge (D→F) has value 0
A 2 B C 2 D R=0 1 E F Regenerating path from the profile result • Example: path register is 4 • Regenerated path is ABDF
Transforming general CFG to acyclic DAG • If there is a backedge (E → B) • Insert dummy edge (entry → B) • Insert dummy edge (E →exit) • Remove the backedge (E→B)
Experiment result • PP : path profiling • QPT : edge profiling • PP’s overhead averaged 2.8 times QPT overhead
Experiment result • Correct : the fraction of paths predicted entirely correctly by edge profiling
Conclusion = Introduction • New path profiling algorithm • Simple • Fast • Minimized run-time overhead • Efficient edge profiling : average overhead 16% • Efficient path profiling : average overhead 31%