From d5a8074b5388518871a949093e34f44d735157e7 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Sat, 27 Jul 2024 09:51:44 +0300 Subject: Add profile-with-tracy-ondemand feature Finally this can be added without disabling frames. manual-lifetime is needed to avoid initializing Tracy for CLI commands, since that is quite slow. --- Cargo.toml | 2 ++ wiki/Developing-niri.md | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4b6342a0..1b58f146 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -116,6 +116,8 @@ systemd = ["dbus"] xdp-gnome-screencast = ["dbus", "pipewire"] # Enables the Tracy profiler instrumentation. profile-with-tracy = ["profiling/profile-with-tracy", "tracy-client/default"] +# Enables the on-demand Tracy profiler instrumentation. +profile-with-tracy-ondemand = ["profile-with-tracy", "tracy-client/ondemand", "tracy-client/manual-lifetime"] # Enables dinit integration (global environment). dinit = [] diff --git a/wiki/Developing-niri.md b/wiki/Developing-niri.md index f30bfb3c..8fd93e89 100644 --- a/wiki/Developing-niri.md +++ b/wiki/Developing-niri.md @@ -49,10 +49,19 @@ The `niri-visual-tests` sub-crate is a GTK application that runs hard-coded test We have integration with the [Tracy](https://github.com/wolfpld/tracy) profiler which you can enable by building niri with a feature flag: ``` -cargo build --release --features=profile-with-tracy +cargo build --release --features=profile-with-tracy-ondemand ``` -Then you can open Tracy (you will need the latest stable release) and attach to a running niri instance to collect profiling data. This is **not** currently "on-demand" (until the next Tracy release), so niri will always collect profiling data when compiled this way, and you can't run a build like this as your main compositor. +Then you can open Tracy (you will need the latest stable release) and attach to a running niri instance to collect profiling data. Profiling data is collected "on demand"---that is, only when Tracy is connected. You can run a niri build like this as your main compositor if you'd like. + +> [!NOTE] +> If you need to profile niri startup or the niri CLI, you can opt for "always on" profiling instead, using this feature flag: +> +> ``` +> cargo build --release --features=profile-with-tracy +> ``` +> +> When compiled this way, niri will **always** collect profiling data, so you can't run a build like this as your main compositor. To make a niri function show up in Tracy, instrument it like this: @@ -62,4 +71,4 @@ pub fn some_function() { // Code of the function. } -``` \ No newline at end of file +``` -- cgit