{"id":3355,"date":"2018-03-21T00:02:06","date_gmt":"2018-03-21T00:02:06","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/pix\/?page_id=3355"},"modified":"2018-03-21T00:02:06","modified_gmt":"2018-03-21T00:02:06","slug":"collecting-cpu-samples-in-timing-captures","status":"publish","type":"page","link":"https:\/\/devblogs.microsoft.com\/pix\/collecting-cpu-samples-in-timing-captures\/","title":{"rendered":"Collecting CPU Samples in Timing Captures"},"content":{"rendered":"<p>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.<\/p>\n<p>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.<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2018\/03\/pix_sparse_instrumentation.png\"><img decoding=\"async\" width=\"778\" height=\"465\" class=\"alignnone size-full wp-image-3365\" alt=\"\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2018\/03\/pix_sparse_instrumentation.png\" srcset=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2018\/03\/pix_sparse_instrumentation.png 778w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2018\/03\/pix_sparse_instrumentation-300x179.png 300w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2018\/03\/pix_sparse_instrumentation-768x459.png 768w\" sizes=\"(max-width: 778px) 100vw, 778px\" \/><\/a><\/p>\n<p><span style=\"color: #000000;font-family: Calibri\">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.<\/span><\/p>\n<p><span style=\"color: #000000;font-family: Calibri\">Before collecting samples, PIX must be configured to find your title\u2019s PDBs.<span>\u00a0 <\/span>Symbol information in the PDBs is used to display function names for the CPU samples PIX collects.<span>\u00a0 <\/span>See <a href=\"https:\/\/devblogs.microsoft.com\/pix\/configuring-pix-to-access-pdbs-for-cpu-captures\/\">Configuring PIX to access CPU PDBs<\/a> for more information.<\/span><\/p>\n<p><span style=\"color: #000000;font-family: Calibri\">To collect CPU samples, select the <strong>Capture CPU Samples<\/strong> checkbox on the Timing Capture options pane.<\/span><\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2018\/03\/pix_cpu_samples_option.png\"><img decoding=\"async\" width=\"494\" height=\"476\" class=\"alignnone size-full wp-image-3375\" alt=\"\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2018\/03\/pix_cpu_samples_option.png\" srcset=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2018\/03\/pix_cpu_samples_option.png 494w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2018\/03\/pix_cpu_samples_option-300x289.png 300w\" sizes=\"(max-width: 494px) 100vw, 494px\" \/><\/a><\/p>\n<p><span style=\"color: #000000;font-family: Calibri\">Collecting samples causes PIX to add one additional lane to the Timeline for each thread or core.<span>\u00a0 <\/span>The samples are displayed on this new \u201cFunctions\u201d lane.<span>\u00a0 <\/span>Samples are drawn as small rectangles.<span>\u00a0 <\/span>The following picture shows several samples that were collected during the time a single long PIX event was executing:<\/span><\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2018\/03\/pix_basic_samples.png\"><img decoding=\"async\" width=\"766\" height=\"400\" class=\"alignnone size-full wp-image-3385\" alt=\"\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2018\/03\/pix_basic_samples.png\" srcset=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2018\/03\/pix_basic_samples.png 766w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2018\/03\/pix_basic_samples-300x157.png 300w\" sizes=\"(max-width: 766px) 100vw, 766px\" \/><\/a><\/p>\n<p><span style=\"color: #000000;font-family: Calibri\">The current sampling rate is 1ms.<span>\u00a0 <\/span>Future versions of PIX will allow you to tune this sampling rate for finer control over level of detail and overhead.<\/span><\/p>\n<p><span style=\"color: #000000;font-family: Calibri\">Selecting a sample causes the Event Details view to be populated with the callstack for the sample.<\/span><\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2018\/03\/pix_samples_detailsview.png\"><img decoding=\"async\" width=\"1173\" height=\"502\" class=\"alignnone size-full wp-image-3395\" alt=\"\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2018\/03\/pix_samples_detailsview.png\" srcset=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2018\/03\/pix_samples_detailsview.png 1173w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2018\/03\/pix_samples_detailsview-300x128.png 300w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2018\/03\/pix_samples_detailsview-768x329.png 768w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2018\/03\/pix_samples_detailsview-1024x438.png 1024w\" sizes=\"(max-width: 1173px) 100vw, 1173px\" \/><\/a><\/p>\n<p><span style=\"color: #000000;font-family: Calibri\">The column of checkboxes in the <strong>Tracked<\/strong> 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.<span>\u00a0 <\/span>See <a href=\"https:\/\/blogs.msdn.microsoft.com\/pix\/tracking-functions-in-timing-captures\/\">Tracked Functions in Timing Captures<\/a> for more details.\u00a0<\/span><\/p>\n<p><span style=\"color: #000000;font-family: Calibri\">The Stack Analysis view can also be used to look at samples.<span>\u00a0 <\/span>This view contains a rollup of all samples that were collected during the capture.<span>\u00a0 <\/span>As PIX is collecting samples, it aggregates identical callstacks so you can see which functions and specific callstacks appeared most frequently in the samples.<span>\u00a0 <\/span>Samples are aggregated for each thread in the capture.<\/span><\/p>\n<p><span style=\"color: #000000;font-family: Calibri\">Columns that show the inclusive and exclusive percentages and the inclusive and exclusive counts for each function and callstack are provided.<span>\u00a0 <\/span>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.<\/span><\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2018\/03\/pix_stack_analysisview.png\"><img decoding=\"async\" width=\"1277\" height=\"653\" class=\"alignnone size-full wp-image-3405\" alt=\"\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2018\/03\/pix_stack_analysisview.png\" srcset=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2018\/03\/pix_stack_analysisview.png 1277w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2018\/03\/pix_stack_analysisview-300x153.png 300w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2018\/03\/pix_stack_analysisview-768x393.png 768w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2018\/03\/pix_stack_analysisview-1024x524.png 1024w\" sizes=\"(max-width: 1277px) 100vw, 1277px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1915,"featured_media":4769,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"footnotes":""},"class_list":["post-3355","page","type-page","status-publish","has-post-thumbnail","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/pages\/3355","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/users\/1915"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/comments?post=3355"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/pages\/3355\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/media\/4769"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/media?parent=3355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}