Tracy: A hybrid frame and sampling profiler for games and other applications
github.com
github.com
There's also superluminal (https://superluminal.eu/), but it's closed source/paid - wolfpld (the Tracy author) is responsive and there's a decent set of contributors so switching to a black box on a part of the engineering process that is designed to avoid black boxes isn't very enticing. It also is sketchy/misleading about saying things like "Superluminal is the only sampling profiler that displays the profiling data in a visual UI." which is a big turn-off for someone who's been using/building tools like that for decades :)
It's intended for frame-oriented applications, where you're looking for bottlenecks which delay a frame. Unlike most profilers, where you're concerned about average time, Tracy is most useful when you're concerned about worst-case time. You can find the slowest frame and zoom way in to see what went wrong.
The program has to be instrumented. You add
profiling::finish_frame!()
to be called once per frame. Around scopes of interest, you add profiling::scope!("Event");
then run and look at the result, which is a zoomable timeline. If a profiling scope is using a lot of time, you go back in and add more "scope" calls around subsections of that scope. This gets you more rows on the profile graph and more detail about where time is going.It's more of a microscope than most profilers.
Tracy is also really useful for measuring average time of functions! It gives you the average / median execution time of each function along with a a nice distribution graph, which is far better than any other profiler I've used so far. You can even compare the execution time / distribution between two profiling results, which is really handy when you're doing any optimization work.
Other notable tools that implement a functionality similar to what is provided by Tracy are Optick https://github.com/bombomby/optick and Intel VTune (sadly specific to only Intel processors) in the Threading analysis.
One neat feature is that you can import Chrome traces. Instrument with normal JS perf marker API! The Tracy UI is just so much better for viewing them.
That said, the title confuses me: I am always thinking of Tracy as an instrumented profiler, not a sampling profiler. I only ever used it as instrumented.
Sampling: Profiler takes stack samples of any code, at fixed frequency, gives you rough hotspots. Instrumented: Report sample points to profiler. Requires putting profiling point into the code to be analyzed.