diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-11-02 10:05:28 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-11-02 10:53:55 +0300 |
| commit | e5ca3351153fa6f3d1e3b00806f85058a8182065 (patch) | |
| tree | 6414a4391d261f83b79d3c31f05479e95467f832 | |
| parent | fce5d668783b4bbd5a6cea5e816d5d90a810d8e6 (diff) | |
| download | niri-e5ca3351153fa6f3d1e3b00806f85058a8182065.tar.gz niri-e5ca3351153fa6f3d1e3b00806f85058a8182065.tar.bz2 niri-e5ca3351153fa6f3d1e3b00806f85058a8182065.zip | |
Add Tracy allocation profiling feature flag
| -rw-r--r-- | Cargo.toml | 2 | ||||
| -rw-r--r-- | src/main.rs | 5 | ||||
| -rw-r--r-- | wiki/Developing-niri.md | 2 |
3 files changed, 9 insertions, 0 deletions
@@ -124,6 +124,8 @@ xdp-gnome-screencast = ["dbus", "pipewire"] 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 Tracy allocation profiling. +profile-with-tracy-allocations = ["profile-with-tracy"] # Enables dinit integration (global environment). dinit = [] diff --git a/src/main.rs b/src/main.rs index d0de54a8..1d4ed56f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,6 +33,11 @@ use tracing_subscriber::EnvFilter; const DEFAULT_LOG_FILTER: &str = "niri=debug,smithay::backend::renderer::gles=error"; +#[cfg(feature = "profile-with-tracy-allocations")] +#[global_allocator] +static GLOBAL: tracy_client::ProfiledAllocator<std::alloc::System> = + tracy_client::ProfiledAllocator::new(std::alloc::System, 100); + fn main() -> Result<(), Box<dyn std::error::Error>> { // Set backtrace defaults if not set. if env::var_os("RUST_BACKTRACE").is_none() { diff --git a/wiki/Developing-niri.md b/wiki/Developing-niri.md index 47cbb143..96a9344a 100644 --- a/wiki/Developing-niri.md +++ b/wiki/Developing-niri.md @@ -72,3 +72,5 @@ pub fn some_function() { // Code of the function. } ``` + +You can also enable Rust memory allocation profiling with `--features=profile-with-tracy-allocations`. |
