diff --git a/Cargo.lock b/Cargo.lock index b73df50208365974126949300b3a03d596284028..17cc8313a59bf3da014f3f989385ff75bdd6766b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1460,7 +1460,6 @@ version = "0.1.0" dependencies = [ "anyhow", "log", - "profiling", "simplelog", "windows 0.61.1", "winresource", @@ -5917,6 +5916,7 @@ dependencies = [ "menu", "picker", "pretty_assertions", + "profiling", "project", "schemars 1.0.1", "search", @@ -5925,6 +5925,7 @@ dependencies = [ "settings", "text", "theme", + "tracy-client-sys", "ui", "util", "workspace", @@ -6797,6 +6798,7 @@ dependencies = [ "log", "parking_lot", "pretty_assertions", + "profiling", "rand 0.9.1", "regex", "rope", @@ -6809,6 +6811,8 @@ dependencies = [ "text", "thiserror 2.0.12", "time", + "tracy-client", + "tracy-client-sys", "unindent", "url", "util", @@ -7108,6 +7112,7 @@ dependencies = [ "sum_tree", "taffy", "thiserror 2.0.12", + "tracy-client-sys", "unicode-segmentation", "usvg", "util", @@ -19890,6 +19895,7 @@ dependencies = [ "paths", "postage", "pretty_assertions", + "profiling", "rand 0.9.1", "rpc", "serde", @@ -19899,6 +19905,7 @@ dependencies = [ "smol", "sum_tree", "text", + "tracy-client-sys", "util", "workspace-hack", "zlog", diff --git a/Cargo.toml b/Cargo.toml index 4bc34aa15b154e8672aabf2c298715d6770c5c29..54fc7df60215084d895319ecf05489a27edb9f71 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -667,7 +667,8 @@ tokio = { version = "1" } tokio-tungstenite = { version = "0.26", features = ["__rustls-tls"] } toml = "0.8" tower-http = "0.4.4" -tracy-client = "0.18.2" +tracy-client = { version = "0.18.2", features = ["fibers"] } +tracy-client-sys = { version = "0.26.1", 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/file_finder/Cargo.toml b/crates/file_finder/Cargo.toml index edb7031f939f117ae5d5ec126a1edec58cb157c3..899917adf7030f8c8a3701d0a8fb436f1d71f97b 100644 --- a/crates/file_finder/Cargo.toml +++ b/crates/file_finder/Cargo.toml @@ -33,6 +33,8 @@ ui.workspace = true 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 61a3e469c1570620eae65de62eed79bc918ac07c..42aba4a5fdd3462d9a025531f7580e1ba446cb88 100644 --- a/crates/file_finder/src/file_finder.rs +++ b/crates/file_finder/src/file_finder.rs @@ -122,6 +122,7 @@ impl FileFinder { ); } + #[profiling::function] fn open( workspace: &mut Workspace, separate_history: bool, @@ -151,11 +152,20 @@ impl FileFinder { if project.is_local() { let fs = fs.clone(); Some(cx.background_spawn(async move { - if fs.is_file(&abs_path).await { + 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 { 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/git/Cargo.toml b/crates/git/Cargo.toml index 74656f1d4c86936b630cb8c1b05030f8d46ccb5c..88172aa9ce8be411b3ae1de7f36b097cc665b690 100644 --- a/crates/git/Cargo.toml +++ b/crates/git/Cargo.toml @@ -40,6 +40,9 @@ util.workspace = true uuid.workspace = true futures.workspace = true workspace-hack.workspace = true +profiling.workspace = true +tracy-client-sys.workspace = true +tracy-client.workspace = true [dev-dependencies] pretty_assertions.workspace = true diff --git a/crates/git/src/repository.rs b/crates/git/src/repository.rs index 2e132d4eaca55c9307bf3368c412f77ed6726df2..3a7593e7492a3be1a59ce5a1c5801348ae6cd49d 100644 --- a/crates/git/src/repository.rs +++ b/crates/git/src/repository.rs @@ -626,6 +626,18 @@ pub async fn get_git_committer(cx: &AsyncApp) -> GitCommitter { .await } +#[repr(C)] +#[derive(Copy, Clone)] +struct ___tracy_source_location_data { + pub name: *const ::std::os::raw::c_char, + pub function: *const ::std::os::raw::c_char, + pub file: *const ::std::os::raw::c_char, + pub line: u32, + pub color: u32, +} + +unsafe impl Send for ___tracy_source_location_data {} + impl GitRepository for RealGitRepository { fn reload_index(&self) { if let Ok(mut index) = self.repository.lock().index() { @@ -681,13 +693,28 @@ impl GitRepository for RealGitRepository { .boxed() } + #[profiling::function] fn load_commit(&self, commit: String, cx: AsyncApp) -> BoxFuture<'_, Result> { let Some(working_directory) = self.repository.lock().workdir().map(ToOwned::to_owned) else { return future::ready(Err(anyhow!("no working directory"))).boxed(); }; + dbg!("Load commit"); let git_binary_path = self.any_git_binary_path.clone(); cx.background_spawn(async move { + let name = std::ffi::CString::new("fiber_load_bytes").unwrap(); + let loc = ___tracy_source_location_data { + name: name.as_ptr(), + function: name.as_ptr(), + file: name.as_ptr(), + line: 0, + color: 0, + }; + let zone = unsafe { + // tracy_client_sys::___tracy_fiber_enter(name.as_ptr()); + tracy_client_sys::___tracy_emit_zone_begin(std::mem::transmute(&loc as *const _), 1) + }; + let show_output = util::command::new_smol_command(&git_binary_path) .current_dir(&working_directory) .args([ @@ -796,6 +823,11 @@ impl GitRepository for RealGitRepository { }) } + unsafe { + tracy_client_sys::___tracy_emit_zone_end(zone); + // tracy_client_sys::___tracy_fiber_leave(); + } + Ok(CommitDiff { files }) }) .boxed() diff --git a/crates/gpui/Cargo.toml b/crates/gpui/Cargo.toml index 4544b561c33f4507e8264e4eed46711425ce2a04..f8450f01dbd46ef3f491f4eb76f2b76d0ea378fe 100644 --- a/crates/gpui/Cargo.toml +++ b/crates/gpui/Cargo.toml @@ -101,6 +101,7 @@ 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 diff --git a/crates/gpui/src/executor.rs b/crates/gpui/src/executor.rs index 0b28dd030baff6bc95ede07e50e358660a9c1353..a9788e1350e5d647220fb0362112a517f82cab7b 100644 --- a/crates/gpui/src/executor.rs +++ b/crates/gpui/src/executor.rs @@ -103,7 +103,17 @@ impl Future for Task { fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { match unsafe { self.get_unchecked_mut() } { Task(TaskState::Ready(val)) => Poll::Ready(val.take().unwrap()), - Task(TaskState::Spawned(task)) => task.poll(cx), + Task(TaskState::Spawned(task)) => { + let name = std::ffi::CString::new("Fiber").unwrap(); + unsafe { + tracy_client_sys::___tracy_fiber_enter(name.as_ptr()); + } + let res = task.poll(cx); + unsafe { + tracy_client_sys::___tracy_fiber_leave(); + } + res + } } } } diff --git a/crates/worktree/Cargo.toml b/crates/worktree/Cargo.toml index fdeca37b7ac73759fe9851f722985349e0a183b7..2f6a5c2aec0cd6ce1bdc93a28ed0db70a95e512c 100644 --- a/crates/worktree/Cargo.toml +++ b/crates/worktree/Cargo.toml @@ -37,6 +37,8 @@ log.workspace = true 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 diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index 3daf83a3a12935587a9c3554c4d0a00171690b9d..8bd48685e6b01778fac75027f2866549d45c131b 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::OsStr, + ffi::{CString, OsStr}, fmt, future::Future, mem::{self}, @@ -3084,12 +3084,27 @@ impl language::LocalFile for File { } 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 { fs.load(&abs_path).await }) + + 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 + }) } + #[profiling::function] fn load_bytes(&self, cx: &App) -> Task>> { let worktree = self.worktree.read(cx).as_local().unwrap(); let abs_path = worktree.absolutize(&self.path);