IP Library › Granted Patent US 7,114,150
Granted Patent B2
US 7,114,150 · App. 10/365,991 · Granted Sep 26, 2006

Apparatus and method for dynamic instrumenting of code to minimize system perturbation

Assignee: International Business Machines Corporation
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 7,114,150
App. No.
10/365,991
Granted
Sep 26, 2006
Kind
B2
Abstract

An apparatus and method are provided for the dynamic instrumentation of code to minimize system perturbation during tracing of the execution of the code. With the apparatus and method, “hot spots” in the execution of the code are dynamically determined during tracing of the execution of the code. These “hot spots” are dynamically instrumented, i.e. an event hook is inserted, to cause control to be passed to a handler that determines a caller of the “hot spot” method. The method that called the “hot spot” method, or “caller” method, is identified from a call stack and is dynamically instrumented for an appropriate metric so that the next time the calling method is executed, the dynamically inserted hooks are executed. The execution of the hooks in the caller method is continued for a predetermined period, e.g., number of invocations, to get an understanding of the caller method's characteristics. A list of callers of instrumented methods is maintained and used to determine one or more calling methods of the instrumented caller method. One or more of these calling methods may be instrumented and the hooks inserted in the instrumented caller method (called by the one or more calling methods), are removed. In this way, the call graph of the hot spots of a program execution is “walked up” and characterized over time.

Claims (65)

1. A computer implemented method of instrumenting code for tracing of a program, comprising:

identifying a hot spot method of the program:

identifying a caller method that calls the hot spot method;

instrumenting the caller method by inserting one or more hooks into the caller method;

measuring at least one execution characteristic metric using the inserted one or more hooks in the caller method;

determining if the at least one execution characteristic metric has been measured for a predetermine period; and

if the at least one execution characteristic metric has been measured for a predetermined period of time;

identifying at least one calling method that calls the caller method;

instrumenting the at least one calling method; and

removing the one or more hooks from the caller method;

storing the at least one execution characteristic metric in a storage mechanism for analyzing execution of the program and system resource usage.

2. The computer implemented method of claim 1 , wherein identifying a caller method that calls the hot spot method includes:

inserting a hook into the hot spot method, wherein the hook passes control of execution of the hot spot method to a handler method that identifies the caller method.

3. The computer implemented method of claim 1 , wherein identifying a caller method that calls the hot spot method includes:

passing hot spot method information to an instrumented Java Virtual Machine: and

calling, via the Java Virtual Machine, a profiler associated with the Java Virtual Machine, wherein the profiler obtains the identity of the caller method from a Java stack.

4. The computer implemented method of claim 1 , wherein identifying a caller method that calls the hot spot method includes determining if code of the hot spot method is native, jitted or interpreted.

5. The computer implemented method of claim 1 , wherein identifying a hot spot method includes analyzing trace data during a trace of the program to identify a portion of code of the program that is either executed many times or consumes a large amount of processing cycles compared to other portions of code of the program.

6. The computer implemented method of claim 1 , wherein identifying a hot spot method includes using program counter sampling to identify the hot spot method.

7. The computer implemented method of claim 6 , wherein a hot spot method is identified as a method whose number of occurrences of samples in the method exceeds a threshold.

8. The computer implemented method of claim 3 , wherein the hot spot method information includes a thread identifier and a method block address of the hot spot method.

9. The computer implemented method of claim 1 , wherein identifying at least one calling method that calls the caller method includes:

maintaining a list of calling methods that call the caller method;

selecting one or more calling methods from the list of calling methods; and

instrumenting the one or more calling methods.

10. The computer implemented method of claim 2 , further comprising: removing the hook from the hot spot method once the caller method is instrumented.

11. A computer program product in a computer readable medium for instrumenting code for tracing of a program, comprising:

first instructions for identifying a hot spot method of the program;

second instructions for identifying a caller method that calls the hot spot method;

third instructions for instrumenting the caller method by inserting one or more hooks into the caller method;

fourth instructions for measuring at least one execution characteristic metric using the inserted one or more hooks in the caller method;

fifth instructions for storing the at least one execution characteristic metric in a storage mechanism for analyzing execution of the program and system resource usage;

sixth instructions for determining if the at least one execution characteristic metric has been measured for a predetermine period: and

seventh instructions responsive to determine that at least one calling method has not been instrumented for performing the following;

identifying at least one calling method that calls the caller method;

instrumenting the at least one calling method; and

removing the one or more hooks from the caller method.

12. The computer program product of claim 11 , wherein the second instructions for identifying a caller method that calls the hot spot method include:

instructions for inserting a hook into the hot spot method, wherein the hook passes control of execution of the hot spot method to a handler method that identifies the caller method.

13. The computer program product of claim 11 , wherein the second instructions for identifying a caller method that calls the hot spot method include:

instructions for passing hot spot method information to an instrumented Java Virtual Machine; and

instructions for calling, via the Java Virtual Machine, a profiler associated with the Java Virtual Machine, wherein the profiler obtains the identity of the caller method from a Java stack.

14. The computer program product of claim 11 , wherein the second instructions for identifying a caller method that calls the hot spot method include instructions for determining if code of the hot spot method is native, jitted or interpreted.

15. The computer program product of claim 11 , wherein identifying a hot spot method includes using program counter sampling to identify the hot spot method.

16. The computer program product of claim 11 , wherein identifying at least one calling method that calls the caller method includes:

maintaining a list of calling methods that call the caller method;

selecting one or more calling methods from the list of calling methods; and

instrumenting the one or more calling methods.

17. The computer program product of claim 12 , further comprising;

instructions for removing the hook from the hot spot method once the caller method is instrumented.

18. An apparatus for instrumenting code for tracing of a program, comprising:

means for identifying a hot spot method of the program;

means for identifying a caller method that calls the hot spot method, wherein the means for identifying a caller method that calls the hot spot method includes:

means for passing hot spot method information to an instrumented Java Virtual Machine, wherein the hot spot method information includes a thread identifier and a method block address of the hot spot method; and

means for calling, via the Java Virtual Machine, a profiler associated with the Java Virtual Machine, wherein the profiler obtains the identity of the caller method from a Java stack;

means for instrumenting the caller method by inserting one or more hooks into the caller method;

means for measuring at least one execution characteristic metric using the inserted one or more hooks in the caller method; and

means for storing the at least one execution characteristic metric for analyzing execution of the program and system resource usage.

19. A method of instrumenting code for tracing of a program, comprising:

identifying a hot spot method of the program;

identifying a caller method that calls the hot spot method by inserting a hook into the hot spot method, wherein the hook passes control of execution of the hot spot method to a handler method that identifies the caller method;

instrumenting the caller method by inserting one or more hooks into the caller method;

measuring at least one execution characteristic metric using the inserted one or more hooks in the caller method;

storing the at least one execution characteristic metric in a storage mechanism for analyzing execution of the program and system resource usage; and

removing the hook from the hot spot method once the caller method is instrumented.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Feb 13, 2003
From: DIMPSEY, ROBERT TOD; LEVINE, FRANK ELIOT; URQUHART, ROBERT JOHN
To: INTERNATIONAL BUSINESS MACHINES CORPORATION
Reel/Frame 013776/0756 →
Continuity (1)
Related Publication 20040163077A1 · Aug 19, 2004