8000 GitHub - xoofx/ultra: An advanced profiler for .NET and Native Applications on Windows, macOS and Linux · GitHub
[go: up one dir, main page]

Skip to content
xoofxPublic

About

An advanced profiler for .NET and Native Applications on Windows, macOS and Linux

Topics

Resources

Stars

1.2k stars

Watchers

9 watching

Forks

Latest commit

 

History

141 Commits

Folders and files

Repository files navigation

Ultra ci NuGet

Ultra is an advanced profiler for .NET and Native Applications available on Windows, Linux and macOS (Apple Silicon).

📽️ Check this video for a quick tour of ultra! 📽️

✨ Features

  • Sampling profiler - ETW based on Windows (up to 8190 samples/second), kernel perf events on Linux (up to 8190 samples/second, launch or attach), in-process sampler over EventPipe on macOS ARM64 (up to 1000 samples/second)
  • UI based on https://profiler.firefox.com/
    • Traces shareable online: Check this example: ✨ https://share.firefox.dev/3Cya7YW ✨
    • Timeline visualization
    • Flamegraph / Stack Chart visualization
    • Call Tree visualization
    • Marker Chart and Marker Table visualization
  • Precise kernel, native and managed function call stacks
  • Categorization of functions:
    • .NET, .NET JIT, .NET GC, .NET CLR, Native, Kernel
  • .NET GC Memory track
  • JIT Compile Time Event Markers
    • See which function is getting compiled
  • GC Events Markers
    • GC Allocation Ticks: Details about allocations.
    • GCHeapStats: Statistics about the GC
    • GCSuspendEE, GCRestartEE, GC Start, GC Stop events
  • Lightweight trace files - e.g. Generates only a few MB for 10s
  • Built for AI agents and automation:
    • ultra mcp: an MCP server to capture profiles and analyze them (call trees, hotspots, callers, markers...)
    • ultra guide: the workflow for agents and scripts, ultra report: a text overview of a profile
    • --elevate (UAC prompt from a non-admin shell on Windows), --result-file (JSON summary), --stop-file
  • Requires net8.0+ via dotnet global tool
Screenshot of a trace generated by ultra visualized with https://profiler.firefox.com. Check this trace online here!
Profile Screenshot

🧑‍💻 Usage

You need to have installed a .NET 10.0+ SDK

$ dotnet tool install -g Ultra # The command ultra.exe will be available from your PATH

Windows


🚨 The profiler requires to run from an elevated prompt with administrative rights 🚨

This is required to allow to collect full stack traces, including kernel and native functions.


Example: open a terminal with administrative rights, to profile an executable called my_commands.exe:

$ ultra.exe profile -- my_command.exe arg0 arg1 arg2...

⚠️ Notice the -- separator to separate the arguments to ultra.exe from the arguments to the profiled application.

From a terminal without administrative rights, add --elevate: Windows asks for them with a UAC prompt, and the profiling runs in an elevated ultra relayed to your terminal (a launched program still runs as you, not elevated):

$ ultra.exe profile --elevate -- my_command.exe arg0 arg1 arg2...

Profiling a running application just requires the PID of the process to profile:

$ ultra.exe profile 15243 # PID of the process to profile
# Wait for a bit and press only one CTRL+C to stop the profiling

macOS (Apple Silicon)

On macOS, no elevated privileges are required. The profiler injects a 74E7 small sampler library into the launched process to collect native and managed call stacks.

$ ultra profile -- my_command arg0 arg1 arg2...

Current limitations on macOS:

  • Only ARM64 (Apple Silicon) is supported.
  • Only launching a program is supported - attaching to a running process with a PID is not (the sampler library can only be injected at process startup).
  • The maximum sampling frequency is 1000 samples/second (--sampling-interval minimum is 1ms).
  • Kernel call stacks are not collected (user-space native and managed call stacks are).
  • Symbols of system libraries living in the dyld shared cache (e.g. libsystem_pthread.dylib) are not resolved.

Remark: the EventPipe session of the injected sampler still asks the runtime for a stack walk with each of its events, while the sampler sends its call stacks in its own events. Turning these stack walks off (as done for the CLR events on Windows, Linux and macOS) may be useful to lower the overhead of profiling on macOS; it has not been tried on a Mac yet.

🤖 AI agents and automation

ultra guide prints the workflow for AI agents and scripts. In short:

$ ultra profile --elevate --duration 30 --result-file result.json --pid 1234   # capture, JSON summary with the profile files
$ ultra report ultra_my_app_..._pid_1234.json.gz                              # text overview: CPU per thread, top functions

ultra mcp is an MCP server (stdio) that lets your AI coding agent capture profiles (find_processes, start_profiling, get_job_status, stop_job...) and analyze them (get_profile_report, call_tree, call_tree_inverted, find_hotspots, focus_function, query_markers...). Configure your agent to start ultra mcp, e.g. claude mcp add ultra -- ultra mcp, or in .vscode/mcp.json:

{ "servers": { "ultra": { "type": "stdio", "command": "ultra", "args": ["mcp"] } } }

The analysis tools of ultra mcp come from UltraMcp by @KirillOsenkov (MIT license, see THIRD-PARTY-NOTICES.txt).

📖 User Guide

For more details on how to use Ultra, please visit the user guide.

🪪 License

This software is released under the BSD-2-Clause license.

🤗 Author

Alexandre Mutel aka xoofx.

About

An advanced profiler for .NET and Native Applications on Windows, macOS and Linux

Topics

Resources

Stars

1.2k stars

Watchers

9 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages

0