{"id":5117,"date":"2020-10-28T15:59:26","date_gmt":"2020-10-28T22:59:26","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/pix\/?page_id=5117"},"modified":"2021-09-14T17:29:10","modified_gmt":"2021-09-15T00:29:10","slug":"analyzing-win32-file-io-performance-in-timing-captures","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/pix\/analyzing-win32-file-io-performance-in-timing-captures\/","title":{"rendered":"Analyzing Win32 File IO performance in Timing Captures"},"content":{"rendered":"<div class=\"halcyon-chm\">\n<p>PIX <a href=\"https:\/\/devblogs.microsoft.com\/pix\/timing-captures-new\/\">Timing Captures<\/a> include an option to collect data on your title\u2019s use of the Win32 file IO APIs to access files. The data collected for calls to APIs such as ReadFile and WriteFile include the name of the file being accessed, and the offset, size and duration of the access itself. Full callstacks for each file access are also recorded.\u00a0 If your title packages individual assets into a composite archive file, PIX can show which assets within the composite file were accessed if a mapping file is provided.<\/p>\n<p>When file IO data is collected, PIX also computes drive bandwidth and utilization metrics. File IO data is displayed in the <strong>Timeline<\/strong>, <strong>Range Details<\/strong>, <strong>Element Details, <\/strong>and <strong>Metrics<\/strong> views in Timing Captures.<\/p>\n<h3>Capturing Win32 File IO data<\/h3>\n<p>To capture data on Win32 file accesses, select the <strong>File accesses<\/strong> check box when starting a Timing Capture as shown in the following figure.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2020\/10\/pix_timing_fileio_capture_options.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-5119\" src=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2020\/10\/pix_timing_fileio_capture_options.png\" alt=\"Image pix timing fileio capture options\" width=\"510\" height=\"442\" srcset=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2020\/10\/pix_timing_fileio_capture_options.png 510w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2020\/10\/pix_timing_fileio_capture_options-300x260.png 300w\" sizes=\"(max-width: 510px) 100vw, 510px\" \/><\/a><\/p>\n<div>\n<div class=\"halcyon-chm\">\n<h3 id=\"heading-2\">Analyzing Win32 File IO accesses in the Timeline<\/h3>\n<p>PIX creates an IO lane in the <strong>Timeline<\/strong> for each drive on the PC from which files were read. Individual file access are represented by a colored rectangle that contains the name of the file that was accessed. The start of each rectangle and it\u2019s length represent the start time and duration of the access. Details of each access are provided in a tooltip.<\/p>\n<p>The following picture shows several reads of a file named ExampleFileData.dat on the E: drive. Note that several rectangles indicating accesses of ExampleFileData.dat overlap in time and are stacked on top of each other in the lane. This visualization represents several concurrent reads of the file.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2020\/10\/pix_timing_fileio_timeline.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-5121\" src=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2020\/10\/pix_timing_fileio_timeline.png\" alt=\"Image pix timing fileio timeline\" width=\"944\" height=\"377\" srcset=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2020\/10\/pix_timing_fileio_timeline.png 944w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2020\/10\/pix_timing_fileio_timeline-300x120.png 300w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2020\/10\/pix_timing_fileio_timeline-768x307.png 768w\" sizes=\"(max-width: 944px) 100vw, 944px\" \/><\/a><\/p>\n<p>To view Win32 File IO data in a tabular form, select a range of time in the <strong>Timeline<\/strong> and choose the <strong>File IO Events<\/strong> item from the <strong>Items to Show<\/strong> dropdown in the <strong>Range Details<\/strong> view. Viewing timing data in a table is useful for certain scenarios such as sorting the table by the file accesses that took the longest time to complete.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2020\/10\/pix_timing_fileio_range_details.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-5123\" src=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2020\/10\/pix_timing_fileio_range_details.png\" alt=\"Image pix timing fileio range details\" width=\"1199\" height=\"749\" srcset=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2020\/10\/pix_timing_fileio_range_details.png 1199w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2020\/10\/pix_timing_fileio_range_details-300x187.png 300w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2020\/10\/pix_timing_fileio_range_details-1024x640.png 1024w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2020\/10\/pix_timing_fileio_range_details-768x480.png 768w\" sizes=\"(max-width: 1199px) 100vw, 1199px\" \/><\/a><\/p>\n<p>Selecting a row in <strong>Range Details<\/strong> populates the <strong>Element Details<\/strong> view with more detailed data about the file access, including the callstack in your title that initiated the access. Use the <strong>Show in Timeline<\/strong> button to scroll the <strong>Timeline<\/strong> to the point in time when the access occurred.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2020\/10\/pix_timing_fileio_element_details.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-5124\" src=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2020\/10\/pix_timing_fileio_element_details.png\" alt=\"Image pix timing fileio element details\" width=\"1504\" height=\"449\" srcset=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2020\/10\/pix_timing_fileio_element_details.png 1504w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2020\/10\/pix_timing_fileio_element_details-300x90.png 300w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2020\/10\/pix_timing_fileio_element_details-1024x306.png 1024w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2020\/10\/pix_timing_fileio_element_details-768x229.png 768w\" sizes=\"(max-width: 1504px) 100vw, 1504px\" \/><\/a><\/p>\n<h3><\/h3>\n<h4>Analyzing file accesses that occur within archive files<\/h4>\n<p>By default, PIX shows file accesses as seen by the underlying file system. If your title packages individual assets into a composite archive file, the file io profiler built into Timing Captures can now show which assets within the composite file were accessed, but it requires extra information from you, the title developer, to do so.\u00a0 The extra information you supply is in the form of a Mapping File that PIX uses to decode accesses that occur within archive files.\u00a0 A mapping file consists of a list of entries, where each entry specifies the size of a specific asset, along with its offset from the beginning of the archive file.\u00a0 A description for each asset must also be provided. PIX uses this offset and size information to map accesses that occurred within the archive to the specific asset, or set of assets, that was read.\u00a0 It then uses the description supplied for each asset to identify it in various places in the <strong>Timeline<\/strong>, <strong>Range Details<\/strong>, and <strong>Element Details<\/strong> views.<\/p>\n<h5>Mapping File Format<\/h5>\n<p>Mapping files are in .csv format. The format should be easily producible either manually or from the portion of your build system that composes the archives.<\/p>\n<p>The first line of the mapping file must be the file name of the archive file that the entries in the rest of the mapping file apply to.<\/p>\n<p>Example first line:<\/p>\n<p style=\"padding-left: 30px;\">c:\\MockGame_PC\\assets\\armor_assets.packed<\/p>\n<p>The remaining lines in the mapping file identify the individual assets within the archive. Assets are identified by the byte offset within the archive file where the asset is stored, the size of the asset in bytes and a description of the asset. The format of an asset line is<\/p>\n<p style=\"padding-left: 30px;\">&lt;offset&gt;,&lt;size&gt;,&lt;description&gt;<\/p>\n<p>Example asset line:<\/p>\n<p style=\"padding-left: 30px;\">0x000000000001FA0, 8096, armor\\body\\helmet.s<\/p>\n<p>The offset and size values on an asset line can be specified as either hex or decimal numbers.<\/p>\n<p>Mapping files may also contain lines that are comments. PIX will ignore these lines when processing the mapping file. Comments lines start with a #.<\/p>\n<p>Example comment line:<\/p>\n<p style=\"padding-left: 30px;\"># this line is a comment. Ignored by PIX.<\/p>\n<p>An example of a complete mapping file follows:<\/p>\n<p style=\"padding-left: 40px;\">armor_assets.packed<\/p>\n<p style=\"padding-left: 40px;\">0x000000000000000, 8096, armor\\weapons\\sword.s<\/p>\n<p style=\"padding-left: 40px;\">0x000000000001FA0, 8096, armor\\body\\helmet.s<\/p>\n<p style=\"padding-left: 40px;\">0x000000000003F40, 8096, armor\\weapons\\sabre.s<\/p>\n<p style=\"padding-left: 40px;\"># this line is a comment, ignored by PIX<\/p>\n<p style=\"padding-left: 40px;\">0x000000000005EE0, 8096, armor\\body\\mail.s<\/p>\n<p style=\"padding-left: 40px;\">0x000000000007E80, 8096, armor\\body\\gloveR.s<\/p>\n<p style=\"padding-left: 40px;\">0x000000000009E20, 8096, armor\\weapons\\chain.s<\/p>\n<p>&nbsp;<\/p>\n<h5>Working with Mapping Files<\/h5>\n<p>The <strong>Display Options<\/strong> panel in the <strong>Range Details<\/strong> view includes an <strong>Add Mapping Files&#8230;<\/strong> button when <strong>File IO Events<\/strong> is selected from the <strong>Items to Show<\/strong> dropdown.\u00a0 Clicking <strong>Add Mapping Files&#8230;<\/strong> brings up a dialog you can use to select your mapping files(s).<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/08\/mapping_file_button-1.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-5620\" src=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/08\/mapping_file_button-1.png\" alt=\"Image mapping file button\" width=\"1235\" height=\"757\" srcset=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/08\/mapping_file_button-1.png 1235w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/08\/mapping_file_button-1-300x184.png 300w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/08\/mapping_file_button-1-1024x628.png 1024w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/08\/mapping_file_button-1-768x471.png 768w\" sizes=\"(max-width: 1235px) 100vw, 1235px\" \/><\/a><\/p>\n<p>After processing the mapping file(s), PIX displays a dialog indicating whether any warnings or errors were encountered.\u00a0 A description of each warning and error is contained in the <strong>Output<\/strong> view.\u00a0 Note that malformed lines in a mapping file are considered warnings, not error.\u00a0 PIX will skip any malformed lines and continue processing the mapping file.\u00a0 The following picture shows the status dialog and contents of the Output view when errors and warnings are found.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/08\/processed_dialog.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-5621\" src=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/08\/processed_dialog.png\" alt=\"Image processed dialog\" width=\"1150\" height=\"484\" srcset=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/08\/processed_dialog.png 1150w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/08\/processed_dialog-300x126.png 300w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/08\/processed_dialog-1024x431.png 1024w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/08\/processed_dialog-768x323.png 768w\" sizes=\"(max-width: 1150px) 100vw, 1150px\" \/><\/a><\/p>\n<p>The UI is updated with the asset names for each line in the mapping file in which the offset and size match a file access that occurred when the capture was running.\u00a0 The <strong>Range Details<\/strong>, <strong>Element Details<\/strong>, and <strong>Timeline<\/strong> views are all updated with asset names.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/08\/asset_names_in_ui.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-5623\" src=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/08\/asset_names_in_ui.png\" alt=\"Image asset names in ui\" width=\"1430\" height=\"496\" srcset=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/08\/asset_names_in_ui.png 1430w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/08\/asset_names_in_ui-300x104.png 300w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/08\/asset_names_in_ui-1024x355.png 1024w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/08\/asset_names_in_ui-768x266.png 768w\" sizes=\"(max-width: 1430px) 100vw, 1430px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h3>Drive Bandwidth and Utilization Metrics<\/h3>\n<p>When file io data is collected, PIX computes drive utilization and bandwidth counters for each drive on your PC.\u00a0 These counters can be found under the <strong>Derived System Metrics\/Drive Utilization<\/strong> node in the Metrics View Selector Panel.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/07\/file_io_metrics_view-1.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-5576\" src=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/07\/file_io_metrics_view-1.png\" alt=\"Image file io metrics view\" width=\"1404\" height=\"459\" srcset=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/07\/file_io_metrics_view-1.png 1404w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/07\/file_io_metrics_view-1-300x98.png 300w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/07\/file_io_metrics_view-1-1024x335.png 1024w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/07\/file_io_metrics_view-1-768x251.png 768w\" sizes=\"(max-width: 1404px) 100vw, 1404px\" \/><\/a><\/p>\n<p>The integration between views in PIX makes it easy to draw correlations between the disk metrics and the data on individual reads.\u00a0 The following picture shows a custom layout comprised of a <strong>Metrics<\/strong> view, a <strong>Range Details<\/strong> view, and an <strong>Element Details<\/strong> view.\u00a0 The <strong>Range Details<\/strong> view is configured to display data corresponding to the selected time range in the <strong>Metrics<\/strong> view.<\/p>\n<p class=\"\">A period of time is selected in the Metrics view that corresponds to spikes in drive utilization and bandwidth.\u00a0 Selecting <strong>File IO Events<\/strong>\u00a0from the\u00a0<strong>Items to Show<\/strong>\u00a0dropdown in <strong>Range Details<\/strong>, populates the table with the set of file accesses made by the title during that period of time.\u00a0 Selecting an individual access populates the<strong> Element Details<\/strong> view with details about that access, including the callstack of title code that initiated the access.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/07\/file_io_custom_layout.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-5580\" src=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/07\/file_io_custom_layout.png\" alt=\"Image file io custom layout\" width=\"1413\" height=\"793\" srcset=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/07\/file_io_custom_layout.png 1413w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/07\/file_io_custom_layout-300x168.png 300w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/07\/file_io_custom_layout-1024x575.png 1024w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2021\/07\/file_io_custom_layout-768x431.png 768w\" sizes=\"(max-width: 1413px) 100vw, 1413px\" \/><\/a><\/p>\n<h3>Win32 File IO Lane Configurations<\/h3>\n<p>The Lane Selector panel and the Lane Configurations list box can be used to customize the appearance of IO lanes as shown in the following picture. Options to reorder lanes, to display or hide specific lanes, to adjust the color and marker height, and other options are provided.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2020\/10\/pix_timing_fileio_config.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-5125\" src=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2020\/10\/pix_timing_fileio_config.png\" alt=\"Image pix timing fileio config\" width=\"680\" height=\"813\" srcset=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2020\/10\/pix_timing_fileio_config.png 680w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2020\/10\/pix_timing_fileio_config-251x300.png 251w\" sizes=\"(max-width: 680px) 100vw, 680px\" \/><\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>PIX Timing Captures include an option to collect data on your title\u2019s use of the Win32 file IO APIs to access files. The data collected for calls to APIs such as ReadFile and WriteFile include the name of the file being accessed, and the offset, size and duration of the access itself. Full callstacks for [&hellip;]<\/p>\n","protected":false},"author":1915,"featured_media":4769,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5117","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-pix"],"acf":[],"blog_post_summary":"<p>PIX Timing Captures include an option to collect data on your title\u2019s use of the Win32 file IO APIs to access files. The data collected for calls to APIs such as ReadFile and WriteFile include the name of the file being accessed, and the offset, size and duration of the access itself. Full callstacks for [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/posts\/5117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/types\/post"}],"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=5117"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/posts\/5117\/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=5117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/categories?post=5117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/tags?post=5117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}