UIforETW
repository·main·Indexed 40 days ago
https://github.com/randomascii/uiforetwA collection of scripts and binaries for Windows performance analysis using Event Tracing for Windows (ETW) and Xperf. Features include the UIforETW automation tool for recording and managing traces, flame_graph.exe for generating text-based flame graphs from ETL files, and CPUByCommandLine.py for aggregating CPU usage data from WPA exported CSVs. It also provides a specialized WPA profile (CPUUsageByCommandLine.wpaProfile) and tools like DummyChrome to register Chrome's ETW providers.
What's inside UIforETW
- This project provides a DLL designed to emit custom Event Tracing for Windows (ETW) events. Integrating this DLL into your own projects allows you to inject custom events into ETW traces, which can act as signposts or provide additional context during trace analysis. This makes it significantly easier to correlate application-specific logic with system-level events.
Overview of available Xperf scripts and tools
mainThis directory contains several specialized scripts and binaries for working with ETW (Event Tracing for Windows) and Xperf, categorized by their original source blog posts:
Process Tree Analysis
Used to derive process parentage from an Xperf trace.
XperfProcessParentage.pyXperfProcessParentage.wpaProfile
Trace Recording and Batch Automation
Batch files related to recording ETW traces.
etwrecord.bat(and other related batch files)
Symbol Management
Tools for managing symbols, specifically for Chromium/Chrome.
StripChromeSymbols.py: Used to strip symbols, often called byetwrecord.batif using the Chromium symbol server. Requirespdbcopy.exe.RetrieveSymbols.exe: Used byStripChromeSymbols.py. Requires x86 versions ofdbghelp.dllandsymsrv.dll.
CPU Usage Visualization
Converts Xperf data into formats suitable for flame graphs.
xperf_to_collapsedstacks.py
UI for ETW
UIforETW.exe: A graphical interface to make Windows performance analysis easier.
Use DummyChrome to register Chrome's ETW providers
mainTheDummyChromeproject providesDummyChrome.dll, which is used to register Chrome's Event Tracing for Windows (ETW) providers. This approach is used as a simpler alternative to locating the specific installation path of Chrome, which is particularly useful when working with older versions of Chrome that may not have ETW providers natively available or easily accessible.Extend analysis with custom WPA profiles
mainTo add additional types of analysis to the automated export, you must:
- Ensure the appropriate data is being recorded during the
start_tracing.batphase (being mindful not to increase the data rate excessively to avoid affecting the measurements). - Add
.wpaProfilefiles to the configuration to define the specific data you want to be exported.
- Ensure the appropriate data is being recorded during the
Use UIforETW.exe for integrated event emitting and tracing
mainIf you are not in a specialized lab environment requiring separate batch files for tracing, you should useUIforETW.exeinstead ofEventEmitter.exe.UIforETW.exeprovides an integrated experience by both emitting events and controlling the tracing process that listens for them.Install UIforETW and Windows Performance Toolkit (WPT)
mainTo use the scripts and binaries in this directory, you must have the Windows Performance Toolkit (WPT) installed. The most reliable way to set up the environment is to download theetwpackage*.zipfrom the UIforETW releases, unzip it, and runbin\UIforETW.exe. Running this executable will install WPT and provide the necessary environment for the included scripts.bin\UIforETW.exeStart and stop event emitting with EventEmitter.exe
mainThe
EventEmitter.exetool is used to monitor system activity and emit events that can be captured by ETW (Event Tracing for Windows) listeners, such asetwrecord.bat.In lab settings where tracing is controlled by separate batch files, you must run
EventEmitter.exeindependently to provide the event stream. For maximum robustness, it is recommended to execute the-killcommand before starting a new session to ensure no stale processes from previous runs are active.# Kill any existing EventEmitter processes to ensure a clean state bin\EventEmitter.exe -kill # Start emitting events bin\EventEmitter.exeMeasure GPU usage with ETW in a lab scenario
mainThis directory provides a set of scripts to measure GPU usage using Event Tracing for Windows (ETW), designed for lab scenarios like regression testing. The workflow involves starting a trace, running the target workload, and stopping the trace to generate processed reports.
Prerequisites
- Administrator Privileges: Both
start_tracing.batandstop_tracing.batmust be executed from an administrator command prompt. - Windows Performance Toolkit (WPT): The
WPTtools must be available in your systemPATH(either installed or manually copied to the test machine). - Operating System: While designed to work on Windows 7, these scripts have been verified on Windows 10.
- Administrator Privileges: Both
Manage and manipulate ETW traces
mainThe UI provides a trace list that allows you to manage existing recordings in your
tracedir. You can perform the following actions on traces:- Delete traces: Remove unwanted recording files.
- Compress traces: Reduce the storage footprint of traces.
- Explore: Open the trace directory in File Explorer.
- Copy name/path: Copy the trace's file path or name to the clipboard.
- Run StripChromeSymbols.py: Execute the symbol stripping script on a specific trace.
- Rename traces: Use keyboard accelerators (F2 to start renaming, Enter to finish, ESC to cancel) to rename traces and their associated files.
Retrieve PE files using image metadata
mainTo download a specific PE (Portable Executable) file, use
RetrieveSymbolswith the time date stamp, the size of the image, and the executable name.Workflow:
- Run
dumpbin /headers <path_to_exe>. - Extract the time date stamp (from the first line) and the
size of image. - Pass these values to
RetrieveSymbols.
# Example dumpbin output lines: # 54E3AECF time date stamp Tue Feb 17 13:12:47 2015 # D3000 size of image # Command to retrieve the PE file: RetrieveSymbols 54E3AECF D3000 chrome.exe- Run
How to record traces for custom ETW providers using UIforETW
mainTo record ETW traces that capture the events emitted by this DLL, it is recommended to use UIforETW. UIforETW is capable of registering the DLL and recording traces specifically configured to listen to its providers.
For implementation examples, refer to the
UIforETWandETWEventDemoprojects available in the repository.Measure CPU and GPU usage with ETW tracing
mainUse the provided batch scripts to record and analyze CPU and GPU usage in lab scenarios like regression testing.
Prerequisites:
- An Administrator command prompt must be used to run the scripts.
- WPT (Windows Performance Toolkit) must be in your system PATH.
- The scripts are tested on Windows 10, though they may work on Windows 7.
Workflow:
- Create an output directory.
- Start tracing (optionally with
detailedmode). - Perform the action you wish to profile.
- Stop tracing and specify the output directory.
Results are provided as
.csvfiles and a summaryresults.jsonfile.:: 1. Create output directory mkdir %temp%\output :: 2. Start tracing (optionally use 'detailed' flag) start_tracing.bat detailed :: 3. Perform your test/action here... :: 4. Stop tracing and save to the directory stop_tracing.bat %temp%\output