Skip to content

Commit

Permalink
Add a detailed flag to the lab start_tracing.bat
Browse files Browse the repository at this point in the history
When doing lab tracing it is useful to have two different tracing modes.
In one mode a very lightweight trace is recorded in order to get CPU
and GPU usage, and little else. This mode has minimal effect on
performance.

The second mode is a detailed mode that records call stacks on CPU
samples and context switches. This distorts results but gives an ETL
file that can be used to investigate regressions.

If 'detailed' is passed to start_tracing.bat it starts a detailed
trace. Stopping and summarizing the trace is unchanged. The trace
files created will be larger - perhaps 5-10x larger?
  • Loading branch information
randomascii committed Apr 14, 2017
1 parent 8b3f9bd commit 6cc4926
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
15 changes: 9 additions & 6 deletions LabScripts/GeneralTracing/set_vars.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ set DX_Flags=DX:0x2F

:Windows8

rem These are some typical flags used by UIforETW:
rem Kernel flags: Latency+POWER+DISPATCHER+DISK_IO_INIT+FILE_IO+FILE_IO_INIT+VIRT_ALLOC+MEMINFO
rem Stackwalk flags: Profile+CSwitch+ReadyThread+VirtualAlloc+VirtualFree
rem Buffer size flags: -buffersize 1024 -minbuffers 1200 -maxbuffers 1200
rem User session flags: Microsoft-Windows-Win32k:0xfdffffffefffffff+Multi-MAIN+Multi-FrameRate+Multi-Input+Multi-Worker+Microsoft-Windows-Kernel-Memory:0xE0+Microsoft-Windows-Kernel-Power+chrome:0x8000000000000200

rem %temp% should be a good location for temporary traces.
rem Make sure this is a fast drive, preferably an SSD.
set xperftemptracedir=%temp%
Expand All @@ -41,5 +35,14 @@ set userfile=%xperftemptracedir%\user.etl
set SessionName=usersession
set FileName=trace.etl
set FileAndCompressFlags="%FileName%" -compress

rem PROC_THREAD+LOADER are required in order to know what binaries are loaded
rem and what threads are running.
rem CSWITCH records context switch data so that precise CPU usage and context
rem switch counts can be recorded. So, these three flags are our minimum set
rem of kernel providers.
set KernelProviders=PROC_THREAD+LOADER+CSWITCH

rem These user providers record GPU usage, window-in-focus, eventemitter events
rem (if emitted), and process working-set samples.
set UserProviders=%DX_Flags%+Microsoft-Windows-Win32k:0xfdffffffefffffff+Multi-MAIN+Multi-FrameRate+Multi-Input+Multi-Worker+Microsoft-Windows-Kernel-Memory:0xE0
18 changes: 13 additions & 5 deletions LabScripts/GeneralTracing/start_tracing.bat
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,20 @@ rem running. Otherwise the start command will fail with incredibly cryptic
rem errors. Ignore all warnings because in most cases they are expected.
xperf -stop %SessionName% -stop 2>nul

rem PROC_THREAD+LOADER is required in order to know what binaries are loaded
rem what threads are running.
rem CSWITCH records context switch data so that precise CPU usage and contxt
rem switch counts can be recorded.

if "%1" == "detailed" goto detailed
xperf.exe -start %logger% -on %KernelProviders% -buffersize 1024 -minbuffers 60 -maxbuffers 60 -f "%kernelfile%" -start %SessionName% -on %UserProviders% -f "%userfile%
goto skipdetailed
:detailed
rem These are some typical flags used by UIforETW to get more detailed traces,
rem which we optionally enable for lab tracing.
rem This extra information will distort timings. This is particularly true
rem of the CSwitch and ReadyThread stackwalk flags.
set KernelProviders=%KernelProviders%+CSWITCH+DISK_IO+HARD_FAULTS+DPC+INTERRUPT+PROFILE
set KernelProviders=%KernelProviders%+POWER+DISPATCHER+DISK_IO_INIT+FILE_IO+FILE_IO_INIT+VIRT_ALLOC+MEMINFO
set StackWalkFlags=Profile+CSwitch+ReadyThread
xperf.exe -start %logger% -on %KernelProviders% -stackwalk %StackWalkFlags% -buffersize 1024 -minbuffers 160 -maxbuffers 160 -f "%kernelfile%" -start %SessionName% -on %UserProviders% -f "%userfile%
:skipdetailed

rem You have to invoke -capturestate because otherwise the ETW gnomes will not
rem reliably record the user-mode data to your trace. Do not anger the gnomes.
xperf.exe -capturestate %SessionName% %UserProviders%
Expand Down

0 comments on commit 6cc4926

Please sign in to comment.