When you use the Focus filter, you select a single function and the flame graph displays all of the code paths that flow into, and out of, that specific function. A focused graph lets you perform two common tasks:
- Analyzing the aggregate resource consumption of a given function that is called from multiple places.
- Analyzing the proportion of time spent in a function for different callers of the function.
For example, how do you analyze the resource consumption around the
function by using the standard flame graph?
In the next section, we focus the graph on
Sort and answer this question.
The flame graphs on this page were constructed with the Color mode
and Compare to set to the default values of Name and None
Focused graph explained
The graph built by the Focus filter effectively creates two flame graphs for the specified function and joins them together:
In the preceding graph, note that frame corresponding to the
is full width and highlighted. The frame text includes the function name, a
percentage and the number of profiles used for the analysis. In this case,
the metrics indicate that the
Sort function, in aggregate, consumed
8.85% of the CPU time.
The bottom half of the preceding graph treats the function
Sort as the
starting point of a standard flame graph and shows all of its callees.
You can create this part with the standard flame graph using the
Show from frame filter:
The top half of the graph shows the callers of
Sort with the callees
hidden. You can make an approximation of the top half using a series of filters.
Start by adding a Show stacks filter for
Sort. Next, for each function
Sort, add either a Hide stacks or Hide frames. In this
situation, you would add a Hide stacks for
quickSort to eliminate this
function and its children, and then add Hide frames for
Using these filters, the approximation of the top half of the focused graph
shows that the
Sort function is reached through different
call stacks. However, the metrics aren't aggregated so the graph doesn't
illustrate overall metric consumption by
The focused graph is a little different than a graph that just combines the two approximations:
- There is a single frame for the focus function
- The focus function frame is highlighted, is full-width frame, and displays metrics that are the aggregation of all call stacks.
- There are multiple call stacks, each beginning with a
rootframe, so you can view the entire call stack.
Effect of clicking on a frame
When you click a frame in a focused graph, the flame graph is redrawn with that frame's call stack displayed in more detail. If the frame is reached through multiple call stacks, each of those call stacks are displayed. Call stacks that don't include the frame are hidden from view. To restore the graph to its original state, click the frame that corresponds to the focus function.
In the previous example,
Sort is called by
(*byFreq).sort and by
(*byLiteral).sort. To view the call stack for
(*byLiteral).sort in more
detail, click that frame.
You can click another frame and further refine the call stacks being displayed:
To restore a focused flame graph to its original state, click the frame that
displays the value of the Focus filter. In this case, click the gray frame
with the label
Analyzing the graph
The focused flame graph supports the same interactions as the standard flame graph, with the exception of how the flame graph changes when you click a frame and how to restore it to the original state. For information on the behavior for a standard flame graph, go to Click on frame.
For information on the focused graph when you are comparing profiles, go to Focusing a comparison.
Setting the focus filter
There are different methods you can use to set a focus filter but they result in the same graph.
By using the graph
Place your pointer on the frame of interest, and then click Focus in the
The focus function is extracted from the frame.
In this example the flame graph, which is expanded around the function
(*huffmanBitWriter).write, displays three different call stacks:
By using the focus list
To focus the flame graph on a specific function, click List, and then select a row from the Select focus function table:
With this approach, you specify a function to focus on. If the function you selected can be called through different call stacks, each call stack is shown in the flame graph.
You can sort the table rows in
(*compressor).deflate function requires 1.46s to
with 971ms spent in the function itself and the remainder of the time spent in
its call stack.
The percentages columns report that 62% of the total execution time is spent
in the function
(*compressor).deflate, and that 93% of the time, this function,
or a function in its call stack, is executing. Lastly, the count column reports
that there are 2 sequences that invoke the function
When you are comparing profiles, the content of the focus list is different. For more information, go to Focusing a comparison.
By using the filter bar
Click the gray text Add profile data filter in the filter
bar, and then enter
Focus: and a string that identifies
the function to focus on. You can use a substring, including package prefixes,
or the full name. If you supply an ambiguous string, the function that
best matches is selected.
If you prefer, you can click Filters, select Focus, and then enter the identifying string.
If the function you selected can be called through different call stacks, each call stack is shown in the flame graph.
Removing the focus filter
To remove the focus filter, click Close close on the filter chip.
To learn how to compare two profiles, see Comparing profiles.