Method and system for periodic trace sampling for real-time generation of segments of call stack trees augmented with call stack position determination
First Claim
1. A method in a data processing system for profiling a program executing in the data processing system, the method comprising:
- performing sample-based profiling of the executing program;
creating, at a start of each sample period, a tree data structure containing nodes, in which the nodes of the tree data structure represent routines of the program that execute before a sample period; and
generating, for each sample period, nodes for the tree data structure in which the nodes of the tree data structure represent routines of the program that execute during a sample period, wherein the creating produces a result that includes a plurality of tree data structures.
1 Assignment
0 Petitions
Accused Products
Abstract
A method and system for profiling a program using periodic trace sampling is provided. During the execution of the program, sample-based profiling of the executing program is performed—for a predetermined period, a profiler performs trace processing for the program, after which the profiler pauses and does not perform trace processing for a predetermined period or only performs lightweight processing for a predetermined period. The periods controlling the profiler may be selected by a user, and the periods may be measured by temporal or non-temporal metrics. The user may also specify parameters that are used to filter events so that profiling is performed only for specified threads or methods. The profiler cycles through these periods, during which selected events are processed to generate a profile of the execution flows within the program. For each sample period, a tree data structure is generated in which nodes of the tree data structure represent the routines of the program that execute during the sample period, as may be indicated by entry and exit events caused by the execution of the routines. At the start of each sample period, execution flow information may be used to create an initial tree data structure. When the execution of the program is complete, the tree data structures from each sample period are merged into a resulting tree data structure.
223 Citations
30 Claims
-
1. A method in a data processing system for profiling a program executing in the data processing system, the method comprising:
-
performing sample-based profiling of the executing program;
creating, at a start of each sample period, a tree data structure containing nodes, in which the nodes of the tree data structure represent routines of the program that execute before a sample period; and
generating, for each sample period, nodes for the tree data structure in which the nodes of the tree data structure represent routines of the program that execute during a sample period, wherein the creating produces a result that includes a plurality of tree data structures. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
recording execution-related metrics for a sample period in the nodes of the tree data structure.
-
-
3. The method of claim 1 further comprising:
-
obtaining execution flow information at the start of each sample period;
processing the execution flow information to create a new tree data structure to be used during the sample period.
-
-
4. The method of claim 3 further comprising:
performing a stack unwind operation to obtain the execution flow information.
-
5. The method of claim 4 wherein the stack unwind operation is performed on the system call stack.
-
6. The method of claim 5 wherein the stack unwind operation is performed on a lightweight call stack maintained for the profiling functions.
-
7. The method of claim 1 further comprising:
enabling event-based trace processing for user-specified threads.
-
8. The method of claim 1 further comprising:
enabling event-based trace processing for user-specified methods.
-
9. The method of claim 1 further comprising:
constructing the tree data structures in real-time as trace data is generated during execution of the program.
-
10. The method of claim 1 further comprising:
in response to a determination of completion of the execution of the program, merging the plurality of tree data structures into a resulting tree data structure.
-
11. The method of claim 10 wherein the step of merging tree data structures further comprises:
-
generating a root node for an empty tree data structure representing a final tree data structure;
for each tree data structure in the plurality of tree data structures, adding a tree data structure for a sample period to the final tree data structure to create a union of the tree data structure for a sample period and the final tree data structure.
-
-
12. A data processing system for profiling a program executing in the data processing system, the data processing system comprising:
-
performing means for performing sample-based profiling of the executing program;
creating means for creating, at a start of each sample period, a tree data structure containing nodes, in which the nodes of the tree data structure represent routines of the program that execute before a sample period; and
first generating means for generating, for each sample period, nodes for the tree data structure in which the nodes of the tree data structure represent routines of the program that execute during a sample period, wherein the creating produces a result that includes a plurality of tree data structures. - View Dependent Claims (13, 14, 15, 16, 17, 18, 19, 20, 21, 22)
recording means for recording execution-related metrics for a sample period in the nodes of the tree data structure.
-
-
14. The method of claim 12 further comprising:
-
obtaining means for obtaining execution flow information at the start of each sample period; and
processing means for processing the execution flow information to create a new tree data structure to be used during the sample period.
-
-
15. The data processing system of claim 14 further comprising:
performing means for performing a stack unwind operation to obtain the execution flow information.
-
16. The data processing system of claim 15 wherein the stack unwind operation is performed on the system call stack.
-
17. The data processing system of claim 16 wherein the stack unwind operation is performed on a lightweight call stack maintained for the profiling functions.
-
18. The data processing system of claim 12 further comprising:
first enabling means for enabling event-based trace processing for user-specified threads.
-
19. The data processing system of claim 12 further comprising:
second enabling means for enabling event-based trace processing for user-specified methods.
-
20. The data processing system of claim 12 further comprising:
constructing means for constructing the tree data structures in real-time as trace data is generated during execution of the program.
-
21. The data processing system of claim 12 further comprising:
merging means for merging, in response to a determination of completion of the execution of the program, the plurality of tree data structures into a resulting tree data structure.
-
22. The data processing system of claim 21 wherein the merging means for merging tree data structures further comprises:
-
second generating means for generating a root node for an empty tree data structure representing a final tree data structure; and
adding means for adding, for each tree data structure in the plurality of tree data structures, a tree data structure for a sample period to the final tree data structure to create a union of the tree data structure for a sample period and the final tree data structure.
-
-
23. A computer program product in a computer-readable medium for use in a data processing system for profiling an executing program, the computer program product comprising:
-
first instructions for performing sample-based profiling of the executing program;
second instructions for creating, at a start of each sample period, a tree data structure containing nodes, in which the nodes of the tree data structure represent routines of the program that execute before a sample period; and
third instructions for generating, for each sample period, nodes for the tree data structure in which the nodes of the tree data structure represent routines of the program that execute during a sample period, wherein the creating produces a result that includes a plurality of tree data structures. - View Dependent Claims (24, 25, 26, 27, 28, 29, 30)
instructions for recording execution-related metrics for a sample period in the nodes of the tree data structure.
-
-
25. The computer program product of claim 23 further comprising:
-
instructions for obtaining execution flow information at the start of each sample period; and
instructions for processing the execution flow information to create a new tree data structure to be used during the sample period.
-
-
26. The computer program product of claim 25 further comprising:
instructions for performing a stack unwind operation to obtain the execution flow information.
-
27. The computer program product of claim 26 wherein the stack unwind operation is performed on the system call stack.
-
28. The computer program product of claim 27 wherein the stack unwind operation is performed on a lightweight call stack maintained for the profiling functions.
-
29. The computer program product of claim 23 further comprising:
instructions for merging, in response to a determination of completion of the execution of the program, the plurality of tree data structures into a resulting tree data structure.
-
30. The computer program product of claim 29 wherein the instructions for merging tree data structures further comprises:
-
instructions for generating a root node for an empty tree data structure representing a final tree data structure;
instructions for adding, for each tree data structure in the plurality of tree data structures, a tree data structure for a sample period to the final tree data structure to create a union of the tree data structure for a sample period and the final tree data structure.
-
Specification