PIX on Windows

Performance tuning and debugging for DirectX 12 games on Windows

Using the Function Histogram in Function Summary and Callgraph Captures

Identifying the functions that occasionally perform outside of their normal characteristics can be one of the most challenging aspects of tuning your title for optimal CPU performance. It’s often the functions that exhibit these transient performance spikes that cause glitches while your title is running.

Transient Spikes

Function Summary Captures and Callgraph Captures can be used to find functions that have occasional outliers in performance. These capture types record the amount of time each call to a function takes and graphs the results on a histogram. This data can be used to identify outliers. Callgraph captures can then be requested for the outliers to help you determine why the transient spike is occurring in your title.
The histogram is displayed at the bottom of the default layout for function summary captures and callgraph captures. Note the outlier at the far right in the graph in the following figure.
histogram_outlier

The Y axis of the histogram shows the number of calls and the X axis shows the amount of time that each call took.

The Y axis is derived from a histogram with bucket sizes set at 1% of the range between min and max recorded values. While you can’t see the exact duration for each individual call because similar calls will aggregate into the same bucket, you can see the relative distribution of behavior between groups of similarly behaving calls.

The data in the histogram shows you the distribution of the calls recorded during the capture and the time spent in each call. As you scan the graph from left to right you’ll find the calls that took the most amount of time. For example, in the figure above you can see a large group of calls that took less than 30us and an outlier that took almost 55us.

By default, a function summary capture gathers a relatively small amount of profiling data for each function. This is done to minimize the amount of memory used during the capture. When analyzing transient spikes, you may often want to gather data on more calls in order to confirm the trends you’ve seen initially and to get more data with which to do analysis. Clicking the Capture Additional Calls button in the lower left corner of the window will perform another capture that gathers more data. The amount of time the additional capture should run is configurable.

The data for the detailed capture is represented by an additional row labeled Details # in the lower left list box. You can take multiple function detail captures. Each will be represented by an entry in the list box. Selecting a Details capture will display the data for that capture in the histogram. The original capture is graphed in red while the more detailed captures are graphed in green. Typically, the distribution for the original capture will be very similar to that of the detailed captures. The figure below shows the histogram for an original capture that contains 61 calls and a detail capture that contains 301 calls.

histogram_variance

The outlier shown on the far right of the histogram represents a call (or group of calls) that took a significantly longer amount of time than the majority of calls (as represented by the large groupings on the right).

Conditional Callgraph Captures

An additional capture, called a conditional callgraph capture can be obtained to help diagnose why this particular call is taking longer than is typical. A conditional capture will run up until a selected call duration is met, at which point the callgraph for the call that met the criteria will be opened in a new callgraph capture.
To take a conditional capture, start by selecting a time range in the histogram. To select a range, click anywhere in the histogram and drag either to the left or right until your desired range is selected. The range is then highlighted in the histogram. In the figure below, a range that includes the outlier is selected.

range_selection

After highlighting the range, choose the Capture Callgraph for Range button. Selecting this button will initiate a callgraph capture. The capture will run until a call that falls within the selected time duration occurs. Note that it is possible that this capture may never encounter another call that meets the selection criteria. In this case, the capture will eventually time out and the following error dialog is displayed:

histogram_timeout

If the selection criteria is met, a new callgraph capture is opened as shown in the following figure. This capture displays the callgraph for the first function call that met the selection criteria.

histogram_cgc_result