Skip to content

Tracy - a Profiling Dev Tool

First of all, Tracy is a real time, nanosecond resolution, remote telemetry, hybrid frame and sampling profiler for games and other applications.

This issue is a proposal to integrate Tracy inside the Aidge Platform. This will give us a great way to dissect how a program is running and how resources are used. It is a major step toward optimizing performance and identifying bottlenecks. Tracy provides real-time, low-overhead profiling that's far superior to traditional debuggers and logging methods.

  • Exceptional Performance: Unlike other profilers that can significantly slow down an application, Tracy is designed for minimal overhead. This means we can leave it running in production without a substantial performance hit, allowing for continuous monitoring and a clear view of real-world performance issues.

  • Intuitive Visualization: Tracy's main strength lies in its highly detailed, easy-to-read, and interactive timeline view. This visualization allows developers to quickly spot frame drops, excessive memory allocations, and long-running tasks at a glance.

  • Development Dependency only. I could make it so Tracy is a toggleable development dependency. We could even add it to export to see how they run.

CDE1E538-0624-4711-9A6C-835B2DC39C0A

From An Introduction to Tracy Profiler (CppCon)

Key Changes

  • Aidge - CMake Kit will provide a toggleable dev dependency
    • Targets can link to it, every thing else we'll be taken care of by ACK
  • A generated header will be available to introduce Tracy API, where functions will be resolved to no-op if Tracy is disabled (it won't even need to link to Tracy.) aidge/tracy.hpp

Some Notes

  1. To be able to use tracy, the following variables must be set during build time :
  • TRACY_ENABLE ON
  • TRACY_NO_EXIT ON
  1. Tracy functions can already be removed from builds by setting TRACY_ENABLE to ON. Having the generated header from ACK is just a wrapper to be able to not link to it, if we are not using it. If for any reason, this is uncessary, feel free to remove the wrapper.

Some ScreenShots

Pasted_image_20250905173730 Pasted_image_20250905173917

Notable Features

Add your own plots

You can add your own plots very easily with these two macros :

TracyPlotConfig(name,
format, step, fill, color)
TracyPlot(name, value)

See the manual section 3.6 Plotting Data for more information.

CD8FD4F9-5E79-4D51-8CE6-DCD76162133B

Logger

Tracy provide a convenient way to read/search/inspect logs. I could refactor the logger to also send them to Tracy if it is enabled.

0EC520AA-0C09-4099-8116-F589C373865F

System Power Usage (only on Linux)

Added in version 0.10.

Pasted_image_20250905173154

CPU Topology Die

Added in version 0.12.

Pasted_image_20250905173354

Resources

Example

Tracy was integrated in a test export using a convolution. The trace is available here if you want to look at it by yourself : conv_test_export_cpp.tracy

Note

On windows, you can simply download and launch the profiler. On Unix & MacOS, you need to build it from source.

Just in case, some screenshots are also available below: FCD85DC6-9A9F-48BC-A44C-19133F0E97B0

B84D7987-8120-4409-8476-65255DF22F3C

44741496-7653-4EDA-80DC-4635CD5C6AB3

Warning

Export don't compile on windows, even with the clang-cl variant. They only compile with GCC. Furthermore, Makefile is not cross-platform (does not work on windows).

Example workflow to integrate tracy into export

  1. Instead of a makefile, change it to a cmake project a. Write a CMakeLists.txt b. Add acm.cmake and include it. c. Link export with Aidge::instrumentation
  2. Configure & build with -DTRACY_ENABLE=1 -DTRACY_NO_EXIT=1
  3. Annotate code with relevant Tracy markup
  4. Launch Tracy Profiler and click Connect
  5. Launch your export

TODO Tasks

  • Integrate into backend_opencv
  • Integrate into backend_cuda
    • This is blocked by issue #322.
  • Integrate into export
    • This is blocked by issue #1216
    • Integrate into build systems
    • Instrument Layer
  • Fix memory allocation to track be able to track them.
    • Tracy reports errors on how Aidge manages memory (double free?)
Edited by Tristan de Blauwe