diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2023-08-10 14:12:20 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2023-08-10 14:50:51 +0400 |
| commit | 0ed5bad452113eaa55b88c8fc46d36badea43286 (patch) | |
| tree | f3994fb64b3ff7ffcd8816b7da9bc8045f41efd4 | |
| parent | 18b9d0dfccc0917ffcc2cf8017d0a346a8df143b (diff) | |
| download | niri-0ed5bad452113eaa55b88c8fc46d36badea43286.tar.gz niri-0ed5bad452113eaa55b88c8fc46d36badea43286.tar.bz2 niri-0ed5bad452113eaa55b88c8fc46d36badea43286.zip | |
Add tracy profiling under a feature
| -rw-r--r-- | Cargo.lock | 64 | ||||
| -rw-r--r-- | Cargo.toml | 6 | ||||
| -rw-r--r-- | src/handlers/compositor.rs | 4 | ||||
| -rw-r--r-- | src/input.rs | 1 | ||||
| -rw-r--r-- | src/main.rs | 3 | ||||
| -rw-r--r-- | src/niri.rs | 2 | ||||
| -rw-r--r-- | src/tty.rs | 5 | ||||
| -rw-r--r-- | src/winit.rs | 2 |
8 files changed, 87 insertions, 0 deletions
@@ -483,6 +483,19 @@ dependencies = [ ] [[package]] +name = "generator" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cc16584ff22b460a382b7feec54b23d2908d858152e5739a120b949293bd74e" +dependencies = [ + "cc", + "libc", + "log", + "rustversion", + "windows", +] + +[[package]] name = "getrandom" version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -705,6 +718,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" [[package]] +name = "loom" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff50ecb28bb86013e935fb6683ab1f6d3a20016f123c76fd4c27470076ac30f5" +dependencies = [ + "cfg-if", + "generator", + "scoped-tls", + "tracing", + "tracing-subscriber", +] + +[[package]] name = "matchers" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -818,10 +844,12 @@ dependencies = [ "anyhow", "bitflags 2.3.3", "clap", + "profiling", "smithay", "smithay-drm-extras", "tracing", "tracing-subscriber", + "tracy-client", ] [[package]] @@ -1046,6 +1074,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46b2164ebdb1dfeec5e337be164292351e11daf63a05174c6776b2f47460f0c9" dependencies = [ "profiling-procmacros", + "tracy-client", ] [[package]] @@ -1185,6 +1214,12 @@ dependencies = [ ] [[package]] +name = "rustversion" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" + +[[package]] name = "scan_fmt" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1453,6 +1488,26 @@ dependencies = [ ] [[package]] +name = "tracy-client" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "434ecabbda9f67eeea1eab44d52f4a20538afa3e2c2770f2efc161142b25b608" +dependencies = [ + "loom", + "once_cell", + "tracy-client-sys", +] + +[[package]] +name = "tracy-client-sys" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d99f5fc382239d08b6bf05bb6206a585bfdb988c878f2499081d0f285ef7819" +dependencies = [ + "cc", +] + +[[package]] name = "udev" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1760,6 +1815,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] +name = "windows" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +dependencies = [ + "windows-targets 0.48.1", +] + +[[package]] name = "windows-sys" version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -10,9 +10,11 @@ edition = "2021" anyhow = { version = "1.0.72", features = ["backtrace"] } bitflags = "2.3.3" clap = { version = "4.3.21", features = ["derive"] } +profiling = "1.0.9" smithay-drm-extras = { version = "0.1.0", path = "../smithay/smithay-drm-extras" } tracing = "0.1.37" tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } +tracy-client = { version = "0.15.2", default-features = false } [dependencies.smithay] git = "https://github.com/Smithay/smithay" @@ -31,3 +33,7 @@ features = [ "use_system_lib", "wayland_frontend", ] + +[features] +profile-with-tracy = ["profiling/profile-with-tracy", "tracy-client/default"] + diff --git a/src/handlers/compositor.rs b/src/handlers/compositor.rs index b2666f7f..1cd781f6 100644 --- a/src/handlers/compositor.rs +++ b/src/handlers/compositor.rs @@ -24,6 +24,10 @@ impl CompositorHandler for Niri { } fn commit(&mut self, surface: &WlSurface) { + tracy_client::Client::running() + .unwrap() + .message("client commit", 0); + on_commit_buffer_handler::<Self>(surface); if !is_sync_subsurface(surface) { let mut root = surface.clone(); diff --git a/src/input.rs b/src/input.rs index a8f85b3a..227bb330 100644 --- a/src/input.rs +++ b/src/input.rs @@ -20,6 +20,7 @@ impl Niri { change_vt: &mut dyn FnMut(i32), event: InputEvent<I>, ) { + let _span = tracy_client::span!("process_input_event"); trace!("process_input_event"); match event { diff --git a/src/main.rs b/src/main.rs index 7a977bd0..f0083ae4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -52,6 +52,8 @@ fn main() { let cli = Cli::parse(); + let _client = tracy_client::Client::start(); + let mut event_loop = EventLoop::try_new().unwrap(); let has_display = env::var_os("WAYLAND_DISPLAY").is_some() || env::var_os("DISPLAY").is_some(); @@ -103,6 +105,7 @@ fn main() { event_loop .run(None, &mut data, move |data| { // niri is running. + let _span = tracy_client::span!("flush_clients"); data.display.flush_clients().unwrap(); }) .unwrap(); diff --git a/src/niri.rs b/src/niri.rs index 98a21d01..28bc2dfd 100644 --- a/src/niri.rs +++ b/src/niri.rs @@ -163,6 +163,8 @@ impl Niri { } fn redraw(&mut self, backend: &mut dyn Backend) { + let _span = tracy_client::span!("redraw"); + assert!(self.redraw_queued); assert!(!self.waiting_for_vblank); self.redraw_queued = false; @@ -69,6 +69,8 @@ impl Backend for Tty { WaylandSurfaceRenderElement<GlesRenderer>, >], ) { + let _span = tracy_client::span!("Tty::render"); + let output_device = self.output_device.as_mut().unwrap(); let drm_compositor = &mut output_device.drm_compositor; @@ -223,6 +225,9 @@ impl Tty { let tty = data.tty.as_mut().unwrap(); match event { DrmEvent::VBlank(_crtc) => { + tracy_client::Client::running() + .unwrap() + .message("vblank", 0); info!("vblank {metadata:?}"); let output_device = tty.output_device.as_mut().unwrap(); diff --git a/src/winit.rs b/src/winit.rs index 458ff95a..e63ac30c 100644 --- a/src/winit.rs +++ b/src/winit.rs @@ -37,6 +37,8 @@ impl Backend for Winit { WaylandSurfaceRenderElement<GlesRenderer>, >], ) { + let _span = tracy_client::span!("Winit::render"); + let size = self.backend.window_size().physical_size; let damage = Rectangle::from_loc_and_size((0, 0), size); |
