{"id":119,"date":"2020-10-06T15:47:43","date_gmt":"2020-10-06T22:47:43","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/performance-diagnostics\/?p=119"},"modified":"2022-02-09T13:46:37","modified_gmt":"2022-02-09T21:46:37","slug":"wpr-start-and-stop-commands","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wpr-start-and-stop-commands\/","title":{"rendered":"WPR Start and Stop Commands"},"content":{"rendered":"<p>The first step is always the hardest. It is true for WPR too. It becomes even more apparent if you try to get help text for the start command. WPR spits out a page full of texts with complex syntax options.\u00a0 It is like the first time we bought a fancy camera, eager to take a nice shot of a bird in flight but then discovering that choosing the right settings requires reading the manual. This is exactly why WPRUI exists today. It is the &#8220;Auto&#8221; setting in the Camera. Though the \u201cAuto\u201d setting of the fancy camera would take good pictures for the most time, sooner or later, the time comes to spin the dial away from the \u201cAuto\u201d. For that inevitable time, let us decipher the words.<\/p>\n<p>If you are not familiar with WPR, check out the previous <a href=\"https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wpr-intro\/\">WPR intro post<\/a>.<\/p>\n<h5>The first step<\/h5>\n<p>The first step is to type <code>wpr -help<\/code> in the command prompt. WPR provides 2 tiers of help, where the first help tier gives a list of commands about which you can request further help.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-121\" src=\"https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-content\/uploads\/sites\/64\/2020\/09\/wprhelp.png\" alt=\"wpr -help text\" width=\"500\" height=\"246\" srcset=\"https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-content\/uploads\/sites\/64\/2020\/09\/wprhelp.png 708w, https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-content\/uploads\/sites\/64\/2020\/09\/wprhelp-300x148.png 300w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/p>\n<p>If your WPR prints out much longer list of help text, that is because you are running an older build of WPR. Current WPR in <a href=\"https:\/\/www.microsoft.com\/en-us\/software-download\/windowsinsiderpreviewADK\">Windows ADK Insider Preview<\/a> &#8211; Build 20215 (or later) should give you the above text but, the text from older build is okay and should also give you the same help.<\/p>\n<p>The next step is to get help on the start command, by typing <code>wpr -help start<\/code>. The command prints out a very long list of options and explanations. Again, if your WPR prints out much shorter texts i.e. no <code>-onoffscenario<\/code> related options, that is also fine. It is probably because you are executing WPR from the Windows directory where the axeonoffhelper module does not exists. OnOffScenarios are used in measuring preset performance scenarios such as Boot, Standby or Shutdown. We do not need <code>-onoffscenario<\/code> option for the purpose of this post.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-120\" src=\"https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-content\/uploads\/sites\/64\/2020\/09\/wprhelpstart.png\" alt=\"Image wpr help start\" width=\"800\" height=\"667\" srcset=\"https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-content\/uploads\/sites\/64\/2020\/09\/wprhelpstart.png 936w, https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-content\/uploads\/sites\/64\/2020\/09\/wprhelpstart-300x250.png 300w, https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-content\/uploads\/sites\/64\/2020\/09\/wprhelpstart-768x640.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>If we remove <code>-onoff***<\/code> options, the start command becomes much less intimidating. The help text says <code>-start [&lt;filename.wprp&gt;!]&lt;profile&gt;<\/code> over and over. It looks like WPR needs a profile to start with. What is the profile? Is it the file with .wprp extension or something else?<\/p>\n<h5>Profiles : Built-in and Custom<\/h5>\n<p>Profile is basically a preset that describes what we want to collect in the trace. There are two types of profiles, built-in and custom. The built-in profiles are like the modes in camera. The most digital camera provides modes such as Macro, Portrait, and Landscape that the camera manufacturer preset optimum shutter speed, aperture, and etc to take good photo based on the situation. WPR also provides the presets for the well-known areas such as Audio, Video, CPU, Network, and File IO\u00a0 to focus the trace for.<\/p>\n<p>The custom profiles are like the manual mode in camera. You need to know the events and the characteristics of the events. Making custom profiles are not very difficult. Just as with understanding the concept of camera lenses and shutter are the start of the manual mode shot, a few concepts in ETW would give you enough to start authoring the profile. The custom profile uses .wprp as the file extension. However, for the beginners, let us start looking at the presets, the built-in profiles.<\/p>\n<p>WPRUI conveniently shows the built-in profiles in the start UI within the check-box list whereas <code>wpr -profiles<\/code>\u00a0command lists out all built-in profiles.<\/p>\n<p><figure id=\"attachment_128\" aria-labelledby=\"figcaption_attachment_128\" class=\"wp-caption alignnone\" ><img decoding=\"async\" class=\"wp-image-128 size-full\" style=\"font-size: 1rem;\" src=\"https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-content\/uploads\/sites\/64\/2020\/09\/wpruistart_partial.png\" alt=\"Image wprui profiles selection\" width=\"419\" height=\"328\" srcset=\"https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-content\/uploads\/sites\/64\/2020\/09\/wpruistart_partial.png 419w, https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-content\/uploads\/sites\/64\/2020\/09\/wpruistart_partial-300x235.png 300w\" sizes=\"(max-width: 419px) 100vw, 419px\" \/><figcaption id=\"figcaption_attachment_128\" class=\"wp-caption-text\">WPRUI Profiles Selection<\/figcaption><\/figure><\/p>\n<p>&nbsp;<\/p>\n<p><figure id=\"attachment_127\" aria-labelledby=\"figcaption_attachment_127\" class=\"wp-caption alignnone\" ><img decoding=\"async\" class=\"wp-image-127\" src=\"https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-content\/uploads\/sites\/64\/2020\/09\/wpr_profiles.png\" alt=\"Image WPR profiles\" width=\"500\" height=\"508\" srcset=\"https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-content\/uploads\/sites\/64\/2020\/09\/wpr_profiles.png 672w, https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-content\/uploads\/sites\/64\/2020\/09\/wpr_profiles-295x300.png 295w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><figcaption id=\"figcaption_attachment_127\" class=\"wp-caption-text\">WPR profile list<\/figcaption><\/figure><\/p>\n<p>The left side is the name of the profiles and the right side is the description of the profiles. Now, we got the &lt;profile&gt; part of the command <code>wpr -start [&lt;filename.wprp&gt;!]&lt;profile&gt;<\/code> . Since the custom profile <code>&lt;filename.wprp&gt;!<\/code> part is optional, we can start a trace by simply providing any built-in profile name, like below.<\/p>\n<pre class=\"prettyprint\"><strong>To start one profile:<\/strong>\r\nwpr -start CPU\r\nwpr -start VirtualAllocation\r\nWpr -start Network\r\n\r\n<strong>To start multiple profiles in merged sessions:<\/strong>\r\nwpr -start CPU -start VirtualAllocation -start Network<\/pre>\n<h5>Verbosity of Profile : Verbose and Light<\/h5>\n<p>A profile can define two verbosity levels, verbose and light. It is like children&#8217;s building block toy where it comes with either the basic block set or a complete set. It is up to the profile author to decide what events are included in verbose and light variants. In WPR, the difference between the light and verbose variants in built-in profiles are usually the addition of stackwalk events and chatty event providers in verbose profile. One can start with the light profile and if the trace doesn&#8217;t give enough clues to investigate, then proceed with the verbose profile. The verbosity level is the last portion of the cryptic start command format in the help text <code>[&lt;filename.wprp&gt;!]&lt;profile name&gt;[.{light|verbose}]<\/code>.<\/p>\n<pre class=\"prettyprint\">wpr -start CPU.verbose <em>(starts verbose CPU profile)<\/em>\r\nwpr -start CPU <em>(same as above. If verbosity is omitted, verbose is selected)<\/em>\r\nwpr -start CPU.light <em>(starts light CPU profile)<\/em><\/pre>\n<h5>Logging Mode : File and Memory mode<\/h5>\n<p>Whether to log to a file or to memory is a decision we have to make. Many factors can influence the decision. In file mode, events are first collected in the buffer then flushed to the file on the disk sequentially. In memory mode, the events are written to the circular buffers in memory and only at the last moment it becomes a file through the trace merge phase. The file mode is essentially setting EVENT_TRACE_FILE_MODE_SEQUENTIAL to the session property and the memory mode is setting EVENT_TRACE_BUFFERING_MODE.<\/p>\n<p>Which mode to use is really based on the nature of the events and the potential impact on the system where the recording is captured. If I need to capture the trace without losing events for a long period of time, with less impact on memory, then I would use the file mode so that I can keep all the events while avoiding the circular wrap problem. If I need to capture over long period of time but only the end part is important, then I would use the memory mode or the circular file mode. Unless the events are particularly verbose that the writing to file would result in lost events or there is tight storage room for the file to grow, using the file mode make sense for most cases. There are two good articles that explain about the modes and buffers further.<\/p>\n<ul>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/windows-hardware\/test\/wpt\/logging-mode\">Logging Modes<\/a> &#8211; explains the modes in WPR context<\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/previous-versions\/windows\/desktop\/xperf\/sessions\">Sessions<\/a> &#8211; explains the modes and buffers deeper in ETW context<\/li>\n<\/ul>\n<p>By default, the memory mode is selected unless <code>-filemode<\/code> is specified in the command line. When I collect a trace for testing, I use the memory mode almost always for this reason. I don&#8217;t have to type <code>-filemode<\/code> at the end since I have the beefy computer that can spare some memory without a hitch.<\/p>\n<p>At this point we can start any built-in profile in memory or file mode.<\/p>\n<pre class=\"prettyprint\">wpr -start GeneralProfile.Light -filemode <em>(starts GeneralProfile.Light in file mode)<\/em>\r\nwpr -start GeneralProfile.Verbose <em>(starts GeneralProfile.Verbose in memory mode)<\/em><\/pre>\n<p>If we want to start a profile from the custom profile file, assuming that CustomProfile.wprp file has WPRTest profile in Verbose\/Light, and File\/Memory mode, we can start the profile like below.<\/p>\n<pre class=\"prettyprint\">wpr -start CustomProfile.wprp!WPRTest -filemode <em>(starts WPRTest in verbose, file mode)<\/em>\r\nwpr -start CustomProfile.wprp!WPRTest.light <em>(starts WPRTest in light, memory mode)\r\n<\/em><\/pre>\n<h5>The Stop Command<\/h5>\n<p>The last step would be stopping the trace. This is a straight forward step to save the trace to a given file name.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-161\" src=\"https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-content\/uploads\/sites\/64\/2020\/10\/wprhelpstop.png\" alt=\"Image wpr help stop\" width=\"700\" height=\"124\" srcset=\"https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-content\/uploads\/sites\/64\/2020\/10\/wprhelpstop.png 853w, https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-content\/uploads\/sites\/64\/2020\/10\/wprhelpstop-300x53.png 300w, https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-content\/uploads\/sites\/64\/2020\/10\/wprhelpstop-768x136.png 768w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/p>\n<p>Optionally you can give the problem description string, which will be inserted to running trace as an event.<\/p>\n<pre class=\"prettyprint\">wpr -stop myrepro.etl \"repro MyApp slowdown in stop\"<\/pre>\n<p>You can find your custom problem description string in Marks table, WPA GraphExplorer under System Activity.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-162\" src=\"https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-content\/uploads\/sites\/64\/2020\/10\/wpr_marks.png\" alt=\"Image wpr marks\" width=\"600\" height=\"308\" srcset=\"https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-content\/uploads\/sites\/64\/2020\/10\/wpr_marks.png 849w, https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-content\/uploads\/sites\/64\/2020\/10\/wpr_marks-300x154.png 300w, https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-content\/uploads\/sites\/64\/2020\/10\/wpr_marks-768x394.png 768w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>In the example Mark table seen above, each line means<\/p>\n<ul>\n<li>General &#8211; This is a general trace, not one of the onoff scenario<\/li>\n<li>repro MyApp slowdown in stop &#8211;\u00a0 &lt;problem description&gt;, the optional parameter<\/li>\n<li>Wpr_Initiated_Rundown &#8211; Marker to show where the rundown operation started<\/li>\n<li>WPRTest &#8211; the profile name<\/li>\n<\/ul>\n<p><code>-skipPdbGen<\/code> is an optional parameter to avoid ngen and embedded pdb generation in trace merge time. It is useful to skip those pdb generations, if you are not collecting trace for .NET apps. The pdb generation only happens for the .NET modules.\u00a0 The pdb generation can take quite a while (multiple 10s of seconds).<\/p>\n<p>One thing I want to point out is that the stop operation can take a while. If WPR just stops the trace, then the operation wouldn&#8217;t take long at all. Once the running session is stopped, WPR processes the trace and inserts more events such as image ids, and system information. We call this &#8220;Merge&#8221;. Most other trace apps require a separate command to merge the traces after stopping, but wpr does this automatically when stopping the trace. The culprit of the long merge time is the &#8220;Loader&#8221; kernel flag, but it is very important flag that tells about module load\/unload. Without this flag the trace has no symbol information, and without symbols, WPA shows just numbers for processes and stacks.<\/p>\n<p><div class=\"alert alert-warning\"><p class=\"alert-divider\"><i class=\"fabric-icon fabric-icon--Warning\"><\/i><strong>If wpr -stop command fails with Error code: 0x80010106<\/strong><\/p>Please use the insider version of ADK Windows Performance Toolkit, build 19650 or later<\/div><\/p>\n<h5>Closing<\/h5>\n<p>In this post we have looked at the format of <code>wpr -start<\/code> command and reviewed the optional parameters. Now, what seemed to be cryptic format in <code>wpr -help start<\/code> command should make clear sense to you. I didn&#8217;t explain how to start\/stop trace using WPRUI because it is already written in MSDN, and it should be pretty straight forward if you read this post. If you want to look at those articles, here are the links.<\/p>\n<ul>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/windows-hardware\/test\/wpt\/start-a-recording\">Starting trace using WPRUI.exe<\/a><\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/windows-hardware\/test\/wpt\/stop-a-recording\">Stopping trace using WPRUI.exe<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>In this post, we show how to start and stop the trace using WPR. The first step is doing &#8216;wpr -help start&#8217;. The command parameters seems to be cryptic. We explain those parameters in detail with examples.<\/p>\n","protected":false},"author":39815,"featured_media":77,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"image","meta":{"_acf_changed":false,"footnotes":""},"categories":[3],"tags":[6,5,7,9],"class_list":["post-119","post","type-post","status-publish","format-image","has-post-thumbnail","hentry","category-windows-performance-recorder","tag-windows-performance-recorder","tag-wpr","tag-wprui","tag-wpt","post_format-post-format-image"],"acf":[],"blog_post_summary":"<p>In this post, we show how to start and stop the trace using WPR. The first step is doing &#8216;wpr -help start&#8217;. The command parameters seems to be cryptic. We explain those parameters in detail with examples.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-json\/wp\/v2\/posts\/119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-json\/wp\/v2\/users\/39815"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-json\/wp\/v2\/comments?post=119"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-json\/wp\/v2\/posts\/119\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-json\/wp\/v2\/media\/77"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-json\/wp\/v2\/media?parent=119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-json\/wp\/v2\/categories?post=119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/performance-diagnostics\/wp-json\/wp\/v2\/tags?post=119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}