I am creating this post out of order (I was planning to demonstrate I/O when various queries are applied with and without indexes – but that will have to wait for a later time. I will end up using XPERF to analyze the I/O).
XPERF.EXE is the holy grail of server performance analysis. It allows software developers to track what each and every process running on a computer is doing. Powerful stuff…
This power comes at a cost – analysis files grow quickly!
WARNING – I suggest only running this tool in a test environment or a lab. It puts extra load on the tested platform and makes simply huge capture files!
Windows Performance Analysis Tools
The Windows Performance Analysis Toolkit, or WPT, ships with the Windows SDK.
Supported Platforms:
- Windows Vista SP1
- Windows Server 2008
- Windows Server 2008R2
- Windows 7
- Windows XP SP2 – Special Install Required
- Windows Server 2003 SP1 – Special Install Required
Installation Instructions
The Windows 7 SDK (also used for Windows server 2008 and 2008R2) requires .Net 4.0 (it will be installed through the web based install). Download the Windows 7 SDK from:
http://msdn.microsoft.com/en-us/windows/bb980924
This post covers the basics for installing Windows SDK 7.1.
Kick off the web based install (it also can be downloaded as an .ISO file).
Agree to the license terms.
Select the appropriate Install Location.
At a minimum the Windows SDK 7.1 will install the application verifier and debugging tools for Windows. Ensure that the Windows Performance toolkit is selected.
Installing on Windows XP or Server 2003
From the MSDN WPA article:
Windows XP
Windows Performance Analyzer can be used on Windows XP SP2 and Windows Server 2003 SP1 to gather trace information. All operations that require trace decoding must be done on Vista or Windows Server 2008. This includes viewing traces in the Windows Performance Analyzer tool (Xperfview.exe).
In order to capture trace information on Windows XP SP2 or Windows Server 2003 SP1 take the following steps:
1.From the "Windows Performance Analyzer" directory on a Windows Vista or Windows Server 2008 machine copy xperf.exe and perfctrl.dll to a directory that is in the PATH of the Windows XP SP2 or Windows Server 2003 target system.
2.On the Windows XP SP2 or Windows Server 2003 target system, run the trace using standard WPA syntax.
3.Copy the "etl" files to a Windows Vista or Windows Server 2008 system that has a full installation of WPA.
WPT Tools
The WPT tools are made up of:
- Xperf.exe – Captures traces, post-processes traces.
- Xperfview.exe – Presents trace content in the form of interactive graphs and summary tables.
- Xbootmgr.exe – Automates on/off state transitions and captures traces during these transitions.
- Perfctrl.dll – DLL file used by xperf.exe to complete traces.
Collect Data
The WPT tools are designed to produce in-depth performance profiles of Windows operating systems and applications. Xperf.exe is used to both start and stop tracing activates. Xperf.exe is designed to log Kernel Groups. The specific kernel group dealing with Disk calls is DISK_IO.
Execute a DISK_IO trace by executing the following command:
xperf -on DISK_IO
Note that xperf traces can become extremely large. The xperf tool by default records all tracing information to a file called kernel.etl. The file location defaults to C:\. To configure a different logging file location use the –f <filename> parameter.
Xperf –on DISK_IO –f
The trace may be stopped by executing:
Xperf –stop
Once the trace is stopped it can be merged with other files. The –d flag will merge a stopped trace. If the –d flag is used on a running trace the –stop command is implied. The trace will be stopped and merged in one step. Define the location of the ETL file using the <filename>.etl parameter. The processed .ETL file will be written to the directory that xperf –d is executed from.
xperf -d test.etl
Analyzing Results
View graph results by opening the ETL file (or use the Windows Performance Analyzer GUI from the programs menu).
xperf test.etl
This will open the Xperfview.exe graph viewing tool. WPA defaults to the Disk I/O and Disk Utilization graphs.
The tool defaulted to use the Disk I/O and Disk Utilization graphs (this was due to the fact that only Disk I/O was traced). The charts can be customized to display only desired data.
Clicking on the Graphs tab will allow the user to add or remove graphs from the analysis.
The most useful Xperf feature is the Disk I/O Detail Graph. To view the detailed Disk I/O detail chart right-click a region on the Disk I/O or Disk utilization chart and click Detail Graph.
The detail chart will display a graphical representation of all offsets (offsets are also called Logical Block Numbers), and offset accesses. This view will immediately identify random and sequential disk access. Red lines denote forced flushes. Hovering over each data point will detail the type of I/O operation, the start time, end time, location, and the calling process.
Note: Only capturing the DISK_IO counter will not allow Xperf.exe to determine the calling process. Using the DiagEasy flag on startup will capture DISK_IO, Process information, and kernel information. Unfortunately the use of DiagEasy will significantly increase the size of any trace.
More Information
By design this section only covers basic WPA features relating to disk access. WPA is an extremely powerful performance analysis tool.
Detailed WPA features and documents can be accessed via MSDN:
http://msdn.microsoft.com/en-us/library/ff191077.aspx
As you can see this tool provides the same data as Process Explorer, but you don't need to run through configuration steps, or fire up Microsoft Excel to graph the results.
In the coming weeks I will be using XPERF to analyze different queries, the benefits of indexes, and outline a process for integrating performance analysis into an engineering life cycle. Enjoy tinkering with XPERF!