diff --git a/Cargo.toml b/Cargo.toml index efb72fa0c..d0d38dfbd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -204,6 +204,9 @@ metrics = ["dep:metrics-exporter-prometheus"] # Enable runtime tracing/spans collection. tracing = [] +# Changes to help us generate our flamegraphs +flamegraph = [] + # Use Jemalloc as the global allocator jemalloc = ["dep:tikv-jemallocator"] diff --git a/src/config.rs b/src/config.rs index 8331c4455..57ee00884 100644 --- a/src/config.rs +++ b/src/config.rs @@ -149,12 +149,20 @@ impl CommonConfig { // identify async threads let async_id = ASYNC_ID.fetch_add(1, Ordering::SeqCst); if async_id <= num_async_threads { - return format!("tokio-async-{}", async_id); + if cfg!(feature = "flamegraph") { + return "tokio-async".to_string(); + } else { + return format!("tokio-async-{}", async_id); + } } // identify blocking threads let blocking_id = BLOCKING_ID.fetch_add(1, Ordering::SeqCst); - format!("tokio-blocking-{}", blocking_id) + if cfg!(feature = "flamegraph") { + "tokio-blocking".to_string() + } else { + format!("tokio-blocking-{}", blocking_id) + } }) .build();