PIX includes a CPU sampling profiler that can optionally be run when taking a timing capture. Viewing CPU samples is useful for determining what code is running on a thread or core for portions of your title that either have sparse or no instrumentation with PIX events.
For example, in the following timeline you can see the main thread of this title (AP1) has only one PIX event that spans approximately 32ms of time.
Collecting CPU samples allows you to get a sense for what functions in your title are executing during that time range without having to add further instrumentation, rebuild and redeploy.
Before collecting samples, PIX must be configured to find your title’s PDBs. Symbol information in the PDBs is used to display function names for the CPU samples PIX collects. See Configuring PIX to access CPU PDBs for more information.
To collect CPU samples, select the Capture CPU Samples checkbox on the Timing Capture options pane.
Collecting samples causes PIX to add one additional lane to the Timeline for each thread or core. The samples are displayed on this new “Functions” lane. Samples are drawn as small rectangles. The following picture shows several samples that were collected during the time a single long PIX event was executing:
The current sampling rate is 1ms. Future versions of PIX will allow you to tune this sampling rate for finer control over level of detail and overhead.
Selecting a sample causes the Event Details view to be populated with the callstack for the sample.
The column of checkboxes in the Tracked column allows you to add and remove the functions in the callstack from the list of functions that will be tracked and displayed on the timeline in subsequent captures. See Tracked Functions in Timing Captures for more details.
The Stack Analysis view can also be used to look at samples. This view contains a rollup of all samples that were collected during the capture. As PIX is collecting samples, it aggregates identical callstacks so you can see which functions and specific callstacks appeared most frequently in the samples. Samples are aggregated for each thread in the capture.
Columns that show the inclusive and exclusive percentages and the inclusive and exclusive counts for each function and callstack are provided. The Track and Untrack buttons on the view can be used to manipulate the list of functions that will be tracked in subsequent timing captures.