diff --git a/Cargo.lock b/Cargo.lock index 2f3b01c0522928aaec9e2e4afabfcd5c8d97bee8..23439578115db662a39e67f77ab992c2956dc82a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3131,6 +3131,7 @@ dependencies = [ "parking_lot", "paths", "postage", + "profiling", "rand 0.9.1", "regex", "release_channel", @@ -4653,6 +4654,7 @@ dependencies = [ "paths", "picker", "pretty_assertions", + "profiling", "project", "rpc", "schemars 1.0.1", @@ -5925,7 +5927,6 @@ dependencies = [ "settings", "text", "theme", - "tracy-client-sys", "ui", "util", "workspace", @@ -7112,7 +7113,6 @@ dependencies = [ "taffy", "thiserror 2.0.12", "tracy-client", - "tracy-client-sys", "unicode-segmentation", "usvg", "util", @@ -12134,6 +12134,7 @@ dependencies = [ "postage", "prettier", "pretty_assertions", + "profiling", "rand 0.9.1", "regex", "release_channel", @@ -13963,7 +13964,6 @@ dependencies = [ "futures 0.3.31", "parking_lot", "rand 0.9.1", - "tracy-client-sys", "workspace-hack", ] @@ -14492,6 +14492,7 @@ dependencies = [ "log", "paths", "pretty_assertions", + "profiling", "release_channel", "rust-embed", "schemars 1.0.1", @@ -19904,7 +19905,7 @@ dependencies = [ "smol", "sum_tree", "text", - "tracy-client-sys", + "tracy-client", "util", "workspace-hack", "zlog", diff --git a/Cargo.toml b/Cargo.toml index 0859426dcfa43a20978dde0fc7ccb42dbffb8b20..d1df1d59614313a691217e6d626d769951ac20bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -667,8 +667,7 @@ tokio = { version = "1" } tokio-tungstenite = { version = "0.26", features = ["__rustls-tls"] } toml = "0.8" tower-http = "0.4.4" -tracy-client = { path = "../rust_tracy_client/tracy-client", features = ["fibers"] } -tracy-client-sys = { path = "../rust_tracy_client/tracy-client-sys", features = ["fibers"] } +tracy-client = { version = "0.18.2", features = ["fibers"] } tree-sitter = { version = "0.25.10", features = ["wasm"] } tree-sitter-bash = "0.25.0" tree-sitter-c = "0.23" diff --git a/crates/client/Cargo.toml b/crates/client/Cargo.toml index 86ecb1b34e323289b542d3bd6f48520c50867ad6..5cf022add6a3c9e45f17d44122c8bfcc74104d41 100644 --- a/crates/client/Cargo.toml +++ b/crates/client/Cargo.toml @@ -37,6 +37,7 @@ log.workspace = true parking_lot.workspace = true paths.workspace = true postage.workspace = true +profiling.workspace = true rand.workspace = true regex.workspace = true release_channel.workspace = true diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index e098e7aed52281605c2882514b23c81d2041c6db..1fb12ab656d1ee6af0ca1819cc583fe108b19b52 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -150,6 +150,7 @@ pub fn init_settings(cx: &mut App) { ProxySettings::register(cx); } +#[profiling::function] pub fn init(client: &Arc, cx: &mut App) { let client = Arc::downgrade(client); cx.on_action({ diff --git a/crates/debugger_ui/Cargo.toml b/crates/debugger_ui/Cargo.toml index df4125860f4ab79ce3a55d6b5b4fbb8f8fc64e5e..15050eb2b4d08a2d19372b38ca9d136adf7b2332 100644 --- a/crates/debugger_ui/Cargo.toml +++ b/crates/debugger_ui/Cargo.toml @@ -53,6 +53,7 @@ parse_int.workspace = true paths.workspace = true picker.workspace = true pretty_assertions.workspace = true +profiling.workspace = true project.workspace = true rpc.workspace = true schemars.workspace = true diff --git a/crates/debugger_ui/src/debugger_ui.rs b/crates/debugger_ui/src/debugger_ui.rs index 689e3cd878b574d31963231df9bcff317ea6d64c..69aa57fe577087da4241fc697baa3a54d8ca9864 100644 --- a/crates/debugger_ui/src/debugger_ui.rs +++ b/crates/debugger_ui/src/debugger_ui.rs @@ -114,6 +114,7 @@ actions!( ] ); +#[profiling::function] pub fn init(cx: &mut App) { DebuggerSettings::register(cx); workspace::FollowableViewRegistry::register::(cx); diff --git a/crates/file_finder/Cargo.toml b/crates/file_finder/Cargo.toml index 899917adf7030f8c8a3701d0a8fb436f1d71f97b..4cd4420d8be570788a526deddf4a5da3d8777cdf 100644 --- a/crates/file_finder/Cargo.toml +++ b/crates/file_finder/Cargo.toml @@ -34,7 +34,6 @@ util.workspace = true workspace.workspace = true workspace-hack.workspace = true profiling.workspace = true -tracy-client-sys.workspace = true [dev-dependencies] ctor.workspace = true diff --git a/crates/file_finder/src/file_finder.rs b/crates/file_finder/src/file_finder.rs index 42aba4a5fdd3462d9a025531f7580e1ba446cb88..ce1c48fd8a8fb4be5180768b696e09eb5deedbfc 100644 --- a/crates/file_finder/src/file_finder.rs +++ b/crates/file_finder/src/file_finder.rs @@ -152,20 +152,11 @@ impl FileFinder { if project.is_local() { let fs = fs.clone(); Some(cx.background_spawn(async move { - let name = - std::ffi::CString::new("Fiber: recent navigation history").unwrap(); - unsafe { - tracy_client_sys::___tracy_fiber_enter(name.as_ptr()); - } - let res = if fs.is_file(&abs_path).await { + if fs.is_file(&abs_path).await { Some(FoundPath::new(project_path, abs_path)) } else { None - }; - unsafe { - tracy_client_sys::___tracy_fiber_leave(); } - res })) } else { Some(Task::ready(Some(FoundPath::new(project_path, abs_path)))) diff --git a/crates/gpui/Cargo.toml b/crates/gpui/Cargo.toml index d7483329f73cb31bdf8201658ba8a020fd558080..de9327cdbb97b0681bb5e00280069180c227198a 100644 --- a/crates/gpui/Cargo.toml +++ b/crates/gpui/Cargo.toml @@ -72,6 +72,7 @@ screen-capture = [ "scap", ] windows-manifest = [] +profile-with-tracy = ["dep:tracy-client"] [lib] path = "src/gpui.rs" @@ -101,7 +102,6 @@ parking = "2.0.0" parking_lot.workspace = true postage.workspace = true profiling.workspace = true -tracy-client-sys.workspace = true rand = { optional = true, workspace = true } raw-window-handle = "0.6" refineable.workspace = true @@ -125,7 +125,7 @@ strum.workspace = true sum_tree.workspace = true taffy = "=0.9.0" thiserror.workspace = true -tracy-client.workspace = true +tracy-client = { workspace = true, optional = true } util.workspace = true uuid.workspace = true waker-fn = "1.2.0" diff --git a/crates/project/Cargo.toml b/crates/project/Cargo.toml index 6a5223f33d0864263b36e2eadb4765780ad2128d..83608070410e79ffb3462d67239560c7641214a8 100644 --- a/crates/project/Cargo.toml +++ b/crates/project/Cargo.toml @@ -25,6 +25,7 @@ test-support = [ "dap/test-support", "dap_adapters/test-support", ] +profile-with-tracy = ["worktree/profile-with-tracy"] [dependencies] aho-corasick.workspace = true @@ -61,6 +62,7 @@ parking_lot.workspace = true paths.workspace = true postage.workspace = true prettier.workspace = true +profiling.workspace = true rand.workspace = true regex.workspace = true remote.workspace = true diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index c2a9816a10d09b8b83abfef6ddabd34a1b90de2c..2e607b0c8321031b5fbadae5a9dcff10515d1ab6 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -1000,6 +1000,7 @@ impl Project { AllAgentServersSettings::register(cx); } + #[profiling::function] pub fn init(client: &Arc, cx: &mut App) { connection_manager::init(client.clone(), cx); Self::init_settings(cx); diff --git a/crates/scheduler/Cargo.toml b/crates/scheduler/Cargo.toml index 82536cbe1109ef9df4190988ef4ec1c064e871db..44436b34d490b94588af54b79abfbf3d60974a93 100644 --- a/crates/scheduler/Cargo.toml +++ b/crates/scheduler/Cargo.toml @@ -22,5 +22,4 @@ chrono.workspace = true futures.workspace = true parking_lot.workspace = true rand.workspace = true -tracy-client-sys.workspace = true workspace-hack.workspace = true diff --git a/crates/settings/Cargo.toml b/crates/settings/Cargo.toml index b5cf8a0acfd036767a84a9ac41afc178447ec9f2..1c830f90c88e8f6c29c379338196a3bf7116df73 100644 --- a/crates/settings/Cargo.toml +++ b/crates/settings/Cargo.toml @@ -25,6 +25,7 @@ gpui.workspace = true inventory.workspace = true log.workspace = true paths.workspace = true +profiling.workspace = true release_channel.workspace = true rust-embed.workspace = true schemars.workspace = true diff --git a/crates/settings/src/settings.rs b/crates/settings/src/settings.rs index 6fe078301abab974ba202660319966e7df42027a..6125839a2810b03f16be950c53c9a862b6a77fd1 100644 --- a/crates/settings/src/settings.rs +++ b/crates/settings/src/settings.rs @@ -77,6 +77,7 @@ impl fmt::Display for WorktreeId { #[exclude = "*.DS_Store"] pub struct SettingsAssets; +#[profiling::function] pub fn init(cx: &mut App) { let settings = SettingsStore::new(cx, &default_settings()); cx.set_global(settings); diff --git a/crates/worktree/Cargo.toml b/crates/worktree/Cargo.toml index 2f6a5c2aec0cd6ce1bdc93a28ed0db70a95e512c..6470fe2f7254e497867d3e85fcfe71efec8cf6cb 100644 --- a/crates/worktree/Cargo.toml +++ b/crates/worktree/Cargo.toml @@ -21,6 +21,7 @@ test-support = [ "text/test-support", "util/test-support", ] +profile-with-tracy = ["dep:tracy-client"] [dependencies] anyhow.workspace = true @@ -38,7 +39,6 @@ parking_lot.workspace = true paths.workspace = true postage.workspace = true profiling.workspace = true -tracy-client-sys.workspace = true rpc = { workspace = true, features = ["gpui"] } serde.workspace = true serde_json.workspace = true @@ -47,6 +47,7 @@ smallvec.workspace = true smol.workspace = true sum_tree.workspace = true text.workspace = true +tracy-client = { workspace = true, optional = true } util.workspace = true workspace-hack.workspace = true diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index 8bd48685e6b01778fac75027f2866549d45c131b..b71cb7438ab44cb3fedbdaf485e44ff11d6af75b 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -48,7 +48,7 @@ use std::{ cmp::Ordering, collections::hash_map, convert::TryFrom, - ffi::{CString, OsStr}, + ffi::OsStr, fmt, future::Future, mem::{self}, @@ -3083,25 +3083,15 @@ impl language::LocalFile for File { self.worktree.read(cx).absolutize(&self.path) } + #[profiling::function] fn load(&self, cx: &App) -> Task> { - profiling::scope!("File::load outer"); - dbg!("File::load outer"); let worktree = self.worktree.read(cx).as_local().unwrap(); let abs_path = worktree.absolutize(&self.path); let fs = worktree.fs.clone(); - cx.background_spawn(async move { - dbg!("File::load inner"); - let name = CString::new("Fiber: load file").unwrap(); - unsafe { - tracy_client_sys::___tracy_fiber_enter(name.as_ptr()); - } - let content = fs.load(&abs_path).await; - unsafe { - tracy_client_sys::___tracy_fiber_leave(); - } - content - }) + cx.background_spawn(tracy_client::fiber!("File::load", async move { + fs.load(&abs_path).await + })) } #[profiling::function] @@ -3109,7 +3099,9 @@ impl language::LocalFile for File { let worktree = self.worktree.read(cx).as_local().unwrap(); let abs_path = worktree.absolutize(&self.path); let fs = worktree.fs.clone(); - cx.background_spawn(async move { fs.load_bytes(&abs_path).await }) + cx.background_spawn(tracy_client::fiber!("File::load_bytes", async move { + fs.load_bytes(&abs_path).await + })) } } diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index 52b677cf68e39408f31603a0170d66af0f88429e..0870e42fe08e165e9e57ca59c1af56f4e0a97d6a 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -19,7 +19,7 @@ name = "zed" path = "src/main.rs" [features] -profile-with-tracy = ["dep:tracy-client", "profiling/profile-with-tracy"] +profile-with-tracy = ["dep:tracy-client", "profiling/profile-with-tracy", "gpui/profile-with-tracy", "project/profile-with-tracy"] profile-with-tracy-memory = ["profile-with-tracy"] [dependencies] diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index 054454ae88a550e6c2e1eff965faa4a420f7b719..47179dc4effc5c730ef5d0415e37608ce8e0048c 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -1317,6 +1317,7 @@ fn parse_url_arg(arg: &str, cx: &App) -> String { } } +#[profiling::function] fn load_embedded_fonts(cx: &App) { let asset_source = cx.asset_source(); let font_paths = asset_source.list("fonts").unwrap(); @@ -1399,10 +1400,12 @@ fn eager_load_active_theme_and_icon_theme(fs: Arc, cx: &App) { } /// Spawns a background task to load the user themes from the themes directory. +#[profiling::function] fn load_user_themes_in_background(fs: Arc, cx: &mut App) { cx.spawn({ let fs = fs.clone(); async move |cx| { + profiling::scope!("load_user_themes_in_background"); if let Some(theme_registry) = cx.update(|cx| ThemeRegistry::global(cx)).log_err() { let themes_dir = paths::themes_dir().as_ref(); match fs diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index c4aa661682530ebb1a281313d1debf9272981464..a68bbfeb2a8695bc53631b4b7e051bba816113c5 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -137,6 +137,7 @@ actions!( ] ); +#[profiling::function] pub fn init(cx: &mut App) { #[cfg(target_os = "macos")] cx.on_action(|_: &Hide, cx| cx.hide()); @@ -1222,6 +1223,7 @@ fn open_log_file(workspace: &mut Workspace, window: &mut Window, cx: &mut Contex .detach(); } +#[profiling::function] pub fn handle_settings_file_changes( mut user_settings_file_rx: mpsc::UnboundedReceiver, mut global_settings_file_rx: mpsc::UnboundedReceiver, @@ -1329,6 +1331,7 @@ pub fn handle_settings_file_changes( .detach(); } +#[profiling::function] pub fn handle_keymap_file_changes( mut user_keymap_file_rx: mpsc::UnboundedReceiver, cx: &mut App,