microsoft / profile-explorer

CPU profiling trace viewer
https://github.com/microsoft/profile-explorer
MIT License
19 stars 3 forks source link
arm64 cpu etw performance profiler windows x64

Profile Explorer

Static Badge Static Badge Static Badge

Profile Explorer is a tool for viewing CPU profiling traces collected through the Event Tracing for Windows (ETW) infrastructure on machines with x64 and ARM64 CPUs. Its focus is on presenting the slowest parts of the profiled application through an easy-to-use but detailed UI consisting of several views, such as a hot function list, flame graph, call tree, timeline, assembly code view, and source file view.

The application can be viewed as a companion to Windows Performance Analyzer (WPA), offering some unique features based on the binary analysis it performs and the IDE-like UI, such as easy navigation through disassembly, improved mapping to source lines, displaying the function control-flow graph, viewing of multiple functions at the same time, marking, searching, filtering and much more.

One of the app's key advantages is its performance. It loads traces fast and offers near-instant UI interaction, even for very large traces (over 10 GB ETL files). Most profile processing steps and algorithms are multi-threaded and don't block the UI.

Summary, Flame Graph and Timeline views of a trace:

image

Assembly, Source File and Flow Graph views of a function:

image

Video introduction

https://github.com/user-attachments/assets/d9a281d3-dc92-4cbe-a3e5-80c4588676a2

⬇️ Download

Installers for the latest version:

Use the ARM64 installer if you have a machine with an ARM64 CPU, since it includes a native build of the app (no emulation), otherwise use the x64 installer. Note that the x64 app can open traces taken on ARM64 machines and vice versa.

The app also has a built-in auto-update feature that will notify you when a new version is released and offer to download and install it.
The installers for previous versions can be downloaded from the Releases page.

πŸ“– Documentation

The documentation pages are available here:

https://microsoft.github.io/profile-explorer

The app also has a built-in Help panel that can display the same documentation.
Most views have a question mark icon in the upper-right corner that opens the Help panel on the view's documentation page.

πŸ› οΈ Building

To build the application and its external dependencies, ensure the following build tools are installed on a Windows 11 machine:

From a an admin command-line window, run:

The debug or release build mode is used for the main project; external dependencies are always built in release mode. The admin mode for the command-line is required to register msdia140.dll using regsvr32; it needs to be done once on a machine.

The build script will update the git submodules, build the main project and external dependencies, and then copy the built dependencies and other resources to the output directory.

The output directory with ProfileExplorer.exe will be found at:
src\ProfileExplorerUI\bin\[Debug|Release]\net8.0-windows.

After the initial build, open the solution file src\ProfileExplorer.sln and use the ProfileExplorerUI project as the build and startup target.

πŸ“¦ Publishing and creating the installer

To publish the application and create an installer, from a command-line window run:

This will build the main project as a self-contained application, build the external dependencies, and create the installer executable, with build output files found at:

Currently InnoSetup is used to create the installer and it must be already installed on the machine and iscc.exe found on PATH.

πŸ“‘ Project structure

Below is a high-level overview of the main parts of the application.

Location Description
src/ProfileExplorerUI The main project and application UI, implemented using WPF.
src/ProfileExplorerCore The UI-independent part that defines the intermediate representation (IR), parsing functions, Graphviz and Tree Sitter support, various data structures, algorithms and utilities.
src/ProfileExplorerUITests Unit tests for the ProfileExplorerUI project.
src/ProfileExplorerCoreTests Unit tests for the ProfileExplorerCore project.
src/ManagedProfiler .NET JIT profiler extension for capturing JIT output assembly code.
src/PDBViewer A small utility displaying the contents of PDB debug info files, implemented using WinForms.
src/VSExtension A Visual Studio extension that connects to the application. Not used for profiling functionality.
src/GrpcLib Defines the GRPC protobuf format used by the Visual Studio extension to communicate with the application. Not used for profiling functionality.

The following projects are build from source, as either x64 or native arm64 binaries.

Location Description
src/external/capstone Capstone disassembly framework, submodule.
src/external/graphviz Graphviz graph visualization tools, submodule.
src/external/tree-sitter Tree-sitter parser generator, with support for C/C++, C# and Rust, submodules.
src/external/TreeListView TreeListView, WPF tree list view control.

Profiling architecture

History

The application started as a tool for helping compiler developers interact with and better understand a compiler's intermediate representation (IR). After adding simple support for viewing profile traces, it gradually gained more profiling features and primarily became a profile viewer.

The tool's initial focus on compilers has led to some distinctive features, such as the ability to parse assembly code into an internal IR. This enables an interactive view of assembly code and the visualization of control-flow graphs, for example.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.