diff --git a/Cargo.lock b/Cargo.lock index 17cc8313a59bf3da014f3f989385ff75bdd6766b..5c70b71d43229e4344e6514554c0ebc37bed168a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12079,7 +12079,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3eb8486b569e12e2c32ad3e204dbaba5e4b5b216e9367044f25f1dba42341773" dependencies = [ "profiling-procmacros", - "tracy-client", ] [[package]] @@ -16899,8 +16898,6 @@ dependencies = [ [[package]] name = "tracy-client" version = "0.18.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef54005d3d760186fd662dad4b7bb27ecd5531cdef54d1573ebd3f20a9205ed7" dependencies = [ "loom", "once_cell", @@ -16910,11 +16907,9 @@ dependencies = [ [[package]] name = "tracy-client-sys" version = "0.26.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "319c70195101a93f56db4c74733e272d720768e13471f400c78406a326b172b0" dependencies = [ "cc", - "windows-targets 0.52.6", + "windows-targets 0.48.5", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 54fc7df60215084d895319ecf05489a27edb9f71..1458bd429856c366320754b012cb6f015df2f924 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -667,8 +667,8 @@ tokio = { version = "1" } tokio-tungstenite = { version = "0.26", features = ["__rustls-tls"] } toml = "0.8" tower-http = "0.4.4" -tracy-client = { version = "0.18.2", features = ["fibers"] } -tracy-client-sys = { version = "0.26.1", features = ["fibers"] } +tracy-client = { path = "../rust_tracy_client/tracy-client", features = ["fibers"] } +tracy-client-sys = { path = "../rust_tracy_client/tracy-client-sys", 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/git/src/repository.rs b/crates/git/src/repository.rs index 3a7593e7492a3be1a59ce5a1c5801348ae6cd49d..f347cd6fe56eed54ce1875c357aef498670a044c 100644 --- a/crates/git/src/repository.rs +++ b/crates/git/src/repository.rs @@ -701,135 +701,147 @@ impl GitRepository for RealGitRepository { }; 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([ - "--no-optional-locks", - "show", - "--format=%P", - "-z", - "--no-renames", - "--name-status", - ]) - .arg(&commit) - .stdin(Stdio::null()) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .output() - .await - .context("starting git show process")?; - - let show_stdout = String::from_utf8_lossy(&show_output.stdout); - let mut lines = show_stdout.split('\n'); - let parent_sha = lines.next().unwrap().trim().trim_end_matches('\0'); - let changes = parse_git_diff_name_status(lines.next().unwrap_or("")); + let _zone = tracy_client::span!("load_commit"); + cx.background_spawn( + tracy_client::Client::running() + .expect("tracy client not running") + .with_fiber("load_commit", 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([ + "--no-optional-locks", + "show", + "--format=%P", + "-z", + "--no-renames", + "--name-status", + ]) + .arg(&commit) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .output() + .await + .context("starting git show process")?; - let mut cat_file_process = util::command::new_smol_command(&git_binary_path) - .current_dir(&working_directory) - .args(["--no-optional-locks", "cat-file", "--batch=%(objectsize)"]) - .stdin(Stdio::piped()) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .spawn() - .context("starting git cat-file process")?; - - let mut files = Vec::::new(); - let mut stdin = BufWriter::with_capacity(512, cat_file_process.stdin.take().unwrap()); - let mut stdout = BufReader::new(cat_file_process.stdout.take().unwrap()); - let mut info_line = String::new(); - let mut newline = [b'\0']; - for (path, status_code) in changes { - // git-show outputs `/`-delimited paths even on Windows. - let Some(rel_path) = RelPath::unix(path).log_err() else { - continue; - }; + let show_stdout = String::from_utf8_lossy(&show_output.stdout); + let mut lines = show_stdout.split('\n'); + let parent_sha = lines.next().unwrap().trim().trim_end_matches('\0'); + let changes = parse_git_diff_name_status(lines.next().unwrap_or("")); - match status_code { - StatusCode::Modified => { - stdin.write_all(commit.as_bytes()).await?; - stdin.write_all(b":").await?; - stdin.write_all(path.as_bytes()).await?; - stdin.write_all(b"\n").await?; - stdin.write_all(parent_sha.as_bytes()).await?; - stdin.write_all(b":").await?; - stdin.write_all(path.as_bytes()).await?; - stdin.write_all(b"\n").await?; - } - StatusCode::Added => { - stdin.write_all(commit.as_bytes()).await?; - stdin.write_all(b":").await?; - stdin.write_all(path.as_bytes()).await?; - stdin.write_all(b"\n").await?; - } - StatusCode::Deleted => { - stdin.write_all(parent_sha.as_bytes()).await?; - stdin.write_all(b":").await?; - stdin.write_all(path.as_bytes()).await?; - stdin.write_all(b"\n").await?; - } - _ => continue, - } - stdin.flush().await?; + let mut cat_file_process = util::command::new_smol_command(&git_binary_path) + .current_dir(&working_directory) + .args(["--no-optional-locks", "cat-file", "--batch=%(objectsize)"]) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .context("starting git cat-file process")?; + + let mut files = Vec::::new(); + let mut stdin = + BufWriter::with_capacity(512, cat_file_process.stdin.take().unwrap()); + let mut stdout = BufReader::new(cat_file_process.stdout.take().unwrap()); + let mut info_line = String::new(); + let mut newline = [b'\0']; + for (path, status_code) in changes { + // git-show outputs `/`-delimited paths even on Windows. + let Some(rel_path) = RelPath::unix(path).log_err() else { + continue; + }; + + match status_code { + StatusCode::Modified => { + stdin.write_all(commit.as_bytes()).await?; + stdin.write_all(b":").await?; + stdin.write_all(path.as_bytes()).await?; + stdin.write_all(b"\n").await?; + stdin.write_all(parent_sha.as_bytes()).await?; + stdin.write_all(b":").await?; + stdin.write_all(path.as_bytes()).await?; + stdin.write_all(b"\n").await?; + } + StatusCode::Added => { + stdin.write_all(commit.as_bytes()).await?; + stdin.write_all(b":").await?; + stdin.write_all(path.as_bytes()).await?; + stdin.write_all(b"\n").await?; + } + StatusCode::Deleted => { + stdin.write_all(parent_sha.as_bytes()).await?; + stdin.write_all(b":").await?; + stdin.write_all(path.as_bytes()).await?; + stdin.write_all(b"\n").await?; + } + _ => continue, + } + stdin.flush().await?; - info_line.clear(); - stdout.read_line(&mut info_line).await?; - - let len = info_line.trim_end().parse().with_context(|| { - format!("invalid object size output from cat-file {info_line}") - })?; - let mut text = vec![0; len]; - stdout.read_exact(&mut text).await?; - stdout.read_exact(&mut newline).await?; - let text = String::from_utf8_lossy(&text).to_string(); - - let mut old_text = None; - let mut new_text = None; - match status_code { - StatusCode::Modified => { info_line.clear(); stdout.read_line(&mut info_line).await?; + let len = info_line.trim_end().parse().with_context(|| { - format!("invalid object size output from cat-file {}", info_line) + format!("invalid object size output from cat-file {info_line}") })?; - let mut parent_text = vec![0; len]; - stdout.read_exact(&mut parent_text).await?; + let mut text = vec![0; len]; + stdout.read_exact(&mut text).await?; stdout.read_exact(&mut newline).await?; - old_text = Some(String::from_utf8_lossy(&parent_text).to_string()); - new_text = Some(text); - } - StatusCode::Added => new_text = Some(text), - StatusCode::Deleted => old_text = Some(text), - _ => continue, - } + let text = String::from_utf8_lossy(&text).to_string(); + + let mut old_text = None; + let mut new_text = None; + match status_code { + StatusCode::Modified => { + info_line.clear(); + stdout.read_line(&mut info_line).await?; + let len = info_line.trim_end().parse().with_context(|| { + format!( + "invalid object size output from cat-file {}", + info_line + ) + })?; + let mut parent_text = vec![0; len]; + stdout.read_exact(&mut parent_text).await?; + stdout.read_exact(&mut newline).await?; + old_text = Some(String::from_utf8_lossy(&parent_text).to_string()); + new_text = Some(text); + } + StatusCode::Added => new_text = Some(text), + StatusCode::Deleted => old_text = Some(text), + _ => continue, + } - files.push(CommitFile { - path: rel_path.into(), - old_text, - new_text, - }) - } + files.push(CommitFile { + path: rel_path.into(), + old_text, + new_text, + }) + } - unsafe { - tracy_client_sys::___tracy_emit_zone_end(zone); - // tracy_client_sys::___tracy_fiber_leave(); - } + // unsafe { + // tracy_client_sys::___tracy_emit_zone_end(zone); + // // tracy_client_sys::___tracy_fiber_leave(); + // } - Ok(CommitDiff { files }) - }) + Ok(CommitDiff { files }) + }), + ) .boxed() } diff --git a/crates/gpui/src/executor.rs b/crates/gpui/src/executor.rs index a9788e1350e5d647220fb0362112a517f82cab7b..0b28dd030baff6bc95ede07e50e358660a9c1353 100644 --- a/crates/gpui/src/executor.rs +++ b/crates/gpui/src/executor.rs @@ -103,17 +103,7 @@ 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)) => { - 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 - } + Task(TaskState::Spawned(task)) => task.poll(cx), } } } diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index 52b677cf68e39408f31603a0170d66af0f88429e..3cc06addedbf8f8b4d98e3ca6cfb3f1cb7e47cb4 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"] profile-with-tracy-memory = ["profile-with-tracy"] [dependencies]