tracy: Hook up profiling crate

Jakub Konka created

Change summary

Cargo.lock                 | 24 +++++-------------------
Cargo.toml                 |  5 +----
crates/collab/Cargo.toml   |  4 ++--
crates/gpui/Cargo.toml     |  2 --
crates/gpui/src/app.rs     |  8 ++------
crates/zed/Cargo.toml      |  5 +----
crates/zed/src/main.rs     |  7 ++-----
crates/zed/src/zed-main.rs |  6 ------
8 files changed, 13 insertions(+), 48 deletions(-)

Detailed changes

Cargo.lock 🔗

@@ -7107,7 +7107,6 @@ dependencies = [
  "sum_tree",
  "taffy",
  "thiserror 2.0.12",
- "tracy-client",
  "unicode-segmentation",
  "usvg",
  "util",
@@ -12069,18 +12068,19 @@ dependencies = [
 
 [[package]]
 name = "profiling"
-version = "1.0.16"
+version = "1.0.17"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "afbdc74edc00b6f6a218ca6a5364d6226a259d4b8ea1af4a0ea063f27e179f4d"
+checksum = "3eb8486b569e12e2c32ad3e204dbaba5e4b5b216e9367044f25f1dba42341773"
 dependencies = [
  "profiling-procmacros",
+ "tracy-client",
 ]
 
 [[package]]
 name = "profiling-procmacros"
-version = "1.0.16"
+version = "1.0.17"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a65f2e60fbf1063868558d69c6beacf412dc755f9fc020f514b7955fc914fe30"
+checksum = "52717f9a02b6965224f95ca2a81e2e0c5c43baacd28ca057577988930b6c3d5b"
 dependencies = [
  "quote",
  "syn 2.0.101",
@@ -16890,17 +16890,6 @@ dependencies = [
  "tracing-serde",
 ]
 
-[[package]]
-name = "tracing-tracy"
-version = "0.11.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0eaa1852afa96e0fe9e44caa53dc0bd2d9d05e0f2611ce09f97f8677af56e4ba"
-dependencies = [
- "tracing-core",
- "tracing-subscriber",
- "tracy-client",
-]
-
 [[package]]
 name = "tracy-client"
 version = "0.18.2"
@@ -20369,9 +20358,6 @@ dependencies = [
  "time",
  "title_bar",
  "toolchain_selector",
- "tracing",
- "tracing-subscriber",
- "tracing-tracy",
  "tracy-client",
  "tree-sitter-md",
  "tree-sitter-rust",

Cargo.toml 🔗

@@ -595,7 +595,7 @@ portable-pty = "0.9.0"
 postage = { version = "0.5", features = ["futures-traits"] }
 pretty_assertions = { version = "1.3.0", features = ["unstable"] }
 proc-macro2 = "1.0.93"
-profiling = "1"
+profiling = "1.0.17"
 prost = "0.9"
 prost-build = "0.9"
 prost-types = "0.9"
@@ -667,9 +667,6 @@ tokio = { version = "1" }
 tokio-tungstenite = { version = "0.26", features = ["__rustls-tls"] }
 toml = "0.8"
 tower-http = "0.4.4"
-tracing = "0.1.40"
-tracing-subscriber = { version = "0.3.18", features = ["env-filter", "json", "registry", "tracing-log"] } # workaround for https://github.com/tokio-rs/tracing/issues/2927
-tracing-tracy = { version = "0.11.4", default-features = false, features = ["enable"] }
 tracy-client = { version = "0.18.2", default-features = false, features = ["enable", "demangle"] }
 tree-sitter = { version = "0.25.10", features = ["wasm"] }
 tree-sitter-bash = "0.25.0"

crates/collab/Cargo.toml 🔗

@@ -64,8 +64,8 @@ tokio = { workspace = true, features = ["full"] }
 toml.workspace = true
 tower = "0.4"
 tower-http = { workspace = true, features = ["trace"] }
-tracing.workspace = true
-tracing-subscriber.workspace = true
+tracing = "0.1.40"
+tracing-subscriber = { version = "0.3.18", features = ["env-filter", "json", "registry", "tracing-log"] } # workaround for https://github.com/tokio-rs/tracing/issues/2927
 util.workspace = true
 uuid.workspace = true
 workspace-hack.workspace = true

crates/gpui/Cargo.toml 🔗

@@ -72,7 +72,6 @@ screen-capture = [
     "scap",
 ]
 windows-manifest = []
-tracy = ["dep:tracy-client"]
 
 [lib]
 path = "src/gpui.rs"
@@ -125,7 +124,6 @@ strum.workspace = true
 sum_tree.workspace = true
 taffy = "=0.9.0"
 thiserror.workspace = true
-tracy-client = { workspace = true, optional = true }
 util.workspace = true
 uuid.workspace = true
 waker-fn = "1.2.0"

crates/gpui/src/app.rs 🔗

@@ -129,10 +129,8 @@ pub struct Application(Rc<AppCell>);
 impl Application {
     /// Builds an app with the given asset source.
     #[allow(clippy::new_without_default)]
+    #[profiling::function]
     pub fn new() -> Self {
-        #[cfg(feature = "tracy")]
-        let _zone = tracy_client::span!();
-
         #[cfg(any(test, feature = "test-support"))]
         log::info!("GPUI was compiled in test mode");
 
@@ -174,13 +172,11 @@ impl Application {
 
     /// Start the application. The provided callback will be called once the
     /// app is fully launched.
+    #[profiling::function]
     pub fn run<F>(self, on_finish_launching: F)
     where
         F: 'static + FnOnce(&mut App),
     {
-        #[cfg(feature = "tracy")]
-        let _zone = tracy_client::span!();
-
         let this = self.0.clone();
         let platform = self.0.borrow().platform.clone();
         platform.run(Box::new(move || {

crates/zed/Cargo.toml 🔗

@@ -19,7 +19,7 @@ name = "zed"
 path = "src/main.rs"
 
 [features]
-tracy = ["dep:tracy-client", "dep:tracing", "dep:tracing-subscriber", "dep:tracing-tracy", "gpui/tracy"]
+tracy = ["dep:tracy-client", "profiling/profile-with-tracy"]
 tracy-memory = ["tracy"]
 
 [dependencies]
@@ -150,9 +150,6 @@ theme_selector.workspace = true
 time.workspace = true
 title_bar.workspace = true
 toolchain_selector.workspace = true
-tracing = { workspace = true, optional = true }
-tracing-subscriber = { workspace = true, optional = true }
-tracing-tracy = { workspace = true, optional = true }
 tracy-client = { workspace = true, optional = true }
 ui.workspace = true
 ui_input.workspace = true

crates/zed/src/main.rs 🔗

@@ -174,10 +174,8 @@ fn fail_to_open_window(e: anyhow::Error, _cx: &mut App) {
     }
 }
 
+#[profiling::function]
 pub fn main() {
-    #[cfg(feature = "tracy")]
-    let _zone = tracy_client::span!();
-
     #[cfg(unix)]
     util::prevent_root_execution();
 
@@ -384,8 +382,7 @@ pub fn main() {
     });
 
     app.run(move |cx| {
-        #[cfg(feature = "tracy")]
-        let _zone = tracy_client::span!();
+        profiling::scope!("app_run");
 
         menu::init();
         zed_actions::init();

crates/zed/src/zed-main.rs 🔗

@@ -4,14 +4,8 @@
 pub fn main() {
     #[cfg(feature = "tracy")]
     {
-        use tracing_subscriber::layer::SubscriberExt;
-
         tracy_client::register_demangler!();
         tracy_client::Client::start();
-        tracing::subscriber::set_global_default(
-            tracing_subscriber::registry().with(tracing_tracy::TracyLayer::default()),
-        )
-        .expect("setup tracy layer");
     }
 
     // separated out so that the file containing the main function can be imported by other crates,