Skip to content
Cataclysm: Bright Nights
GitHubDiscord

Profiling with tracy

Tracy is a realtime profiler which you can use to analyze performance bottleneck. It consists of two parts: client and profiler. The client integrated in BN sends profiling data to the profiler. As the client is opt-in, you need to build BN with tracy client in order to start profiling.

Install Tracy Profiler

Linux

$ git clone https://github.com/wolfpld/tracy
$ cd tracy
$ git checkout 6d1deb5640ed11da01995fb1791115cfebe54dbf # the commit used by BN tracy client
  1. Clone https://github.com/wolfpld/tracy.
# for ubuntu (X11)
$ sudo apt install cmake clang git libcapstone-dev xorg-dev dbus libgtk-3-dev

# for ubuntu (wayland)
$ sudo apt install libglfw-dev libgtk-3-dev libfreetype6-dev libtbb-dev debuginfod libwayland-dev dbus libxkbcommon-dev libglvnd-dev meson cmake git wayland-protocols

# for arch, copied from https://github.com/wolfpld/tracy/blob/master/.github/workflows/linux.yml#L16C12-L16C163
$ pacman -Syu --noconfirm && pacman -S --noconfirm --needed freetype2 tbb debuginfod wayland dbus libxkbcommon libglvnd meson cmake git wayland-protocols
  1. Install dependencies.
$ cmake -B profiler/build -S profiler # if you're using wayland
  1. Set up cmake. By default tracy uses wayland, if you want to use X11, you need to add LEGACY=1 flag.
$ cmake --build profiler/build --config Release --parallel $(nproc)
  1. Build the binary. It will be available on ./profiler/build/tracy-profiler.

Windows

image

Download pre-compiled executable from https://github.com/wolfpld/tracy/releases.

Build BN with Tracy Client

Build on cmake with -D USE_TRACY=ON flag. For example,

$ cmake -B build -DUSE_TRACY=ON ...other flags...

See CMake options for more information.

Mark zone to profile

Mark ZoneScoped in the function you’d like to profile. It will be displayed in the tracy GUI. For example,

bool game::do_turn()
{
    ZoneScoped;

    /** Other code... */
}

There are also more complex profiling macros available. Check following links for more:

Use Tracy Profiler

  1. Start BN (built with USE_TRACY=ON), and run the tracy profiler.

  1. Click connect button to connect to the game.

  1. Profiling data will be displayed in the GUI.