Skip to content

Profiling

Daan de Lange edited this page Jun 14, 2022 · 4 revisions

Mosaic has been instrumented with the Tracy Profiler which can be enabled using the MOSAIC_ENABLE_PROFILING and TRACY_ENABLE compiler flags.
Tracy offers a frame-based inspection, which gives an insight into the inner mechanics of Mosaic's underlying engine and its plugins. This can be useful for understanding the inner mechanics of Mosaic, spotting orchestration anomalies, bottlenecks or other bugs. It also visualises memory allocations over time which are useful for spotting memory leaks. Moreover, for more advanced users, Tracy is also great for visualising multi-threaded process orchestration order which are handy to spot race conditions or mutex bottlenecks.

Getting started

Tracy comes in two parts. The client, which is embedded into Mosaic (and optionally compiled), sends profiling information using a standard network protocol. The profiler then collects and visualises the client data; it can run locally or on a remote computer, on the same network. Both versions have to be identical, the profiler will warn you if you use incompatible client version.

You can debug Mosaic running on any computer (Mac/Windows/Linux) with another (Linux) computer running the Profiler on the same network. If using a remote computer, an RJ45 connection is recommended over wifi.
For more information on different ways to use Tracy, checkout its manual.


Compile the profiler

The Tracy profiler is hard to compile on OSX, because it needs a quite modern compiler (C++17). Therefore (,on osx pre-10.12.6), it's recommended to compile (and run) it on Linux.

Linux Profiler installation

  1. Checkout which Tracy version your Mosaic distribution is using in Mosaic/tracy/server/TracyVersion.hpp and download that same version of Tracy, which also contains the profiler. In principle, the git submodule should always be in sync with your Mosaic version: git submodule update profiler/tracy.
  2. Follow the profiler compilation procedure from the Tracy manual that you can find on the releases page.

Mac Profiler installation

// todo

Windows Profiler installation

// todo


Compile Mosaic with profiling enabled

Everything is almost ready, but you need to add a profiling build configuration to your build settings, so that Mosaic acts as a Tracy client.
Note: This may be either on the same or on another computer and/or operating system.

Qt-creator

  1. Open Mosaic in Qt Creator, in the "Projects" section, select Release, then Add > Clone Selected and name it exactly Profiling.
  2. Change Release to Profiling in all fields below. (Build Directory, Configuration Name, Build Steps, Clean Steps)
  3. You can now switch between 3 different build modes. Build the profiling one.

Makefiles

Compile Mosaic with -DTRACY_ENABLE -DTRACY_ONLY_IPV4 -DMOSAIC_ENABLE_PROFILING . See the current version of these lines as a reference.

Run

Start the profiler, enter Mosaic's local IP address and connect. As soon as you launch Mosaic, it should start profiling.

Screenshot

[Todo]

Clone this wiki locally