Compare commits
2 Commits
main
...
agent-perf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a6437de6a | ||
|
|
152df995b9 |
5
Cargo.lock
generated
5
Cargo.lock
generated
@@ -405,6 +405,7 @@ dependencies = [
|
||||
"theme",
|
||||
"time",
|
||||
"time_format",
|
||||
"tracing",
|
||||
"tree-sitter-md",
|
||||
"ui",
|
||||
"ui_input",
|
||||
@@ -415,6 +416,7 @@ dependencies = [
|
||||
"watch",
|
||||
"workspace",
|
||||
"zed_actions",
|
||||
"ztracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -9701,8 +9703,10 @@ dependencies = [
|
||||
"settings",
|
||||
"sum_tree",
|
||||
"theme",
|
||||
"tracing",
|
||||
"ui",
|
||||
"util",
|
||||
"ztracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -20786,6 +20790,7 @@ dependencies = [
|
||||
"watch",
|
||||
"web_search",
|
||||
"web_search_providers",
|
||||
"which 6.0.3",
|
||||
"which_key",
|
||||
"windows 0.61.3",
|
||||
"winresource",
|
||||
|
||||
@@ -103,6 +103,8 @@ zed_actions.workspace = true
|
||||
image.workspace = true
|
||||
async-fs.workspace = true
|
||||
reqwest_client = { workspace = true, optional = true }
|
||||
ztracing.workspace = true
|
||||
tracing.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
acp_thread = { workspace = true, features = ["test-support"] }
|
||||
@@ -124,3 +126,6 @@ semver.workspace = true
|
||||
reqwest_client.workspace = true
|
||||
tree-sitter-md.workspace = true
|
||||
unindent.workspace = true
|
||||
|
||||
[package.metadata.cargo-machete]
|
||||
ignored = ["tracing"]
|
||||
|
||||
@@ -965,6 +965,7 @@ impl Focusable for MessageEditor {
|
||||
}
|
||||
|
||||
impl Render for MessageEditor {
|
||||
#[ztracing::instrument(skip_all)]
|
||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
div()
|
||||
.key_context("MessageEditor")
|
||||
|
||||
@@ -1925,6 +1925,7 @@ impl AcpThreadView {
|
||||
.detach_and_log_err(cx);
|
||||
}
|
||||
|
||||
#[ztracing::instrument(skip_all)]
|
||||
fn render_entry(
|
||||
&self,
|
||||
entry_ix: usize,
|
||||
@@ -2302,6 +2303,7 @@ impl AcpThreadView {
|
||||
rems_from_px(13.)
|
||||
}
|
||||
|
||||
#[ztracing::instrument(skip_all)]
|
||||
fn render_thinking_block(
|
||||
&self,
|
||||
entry_ix: usize,
|
||||
@@ -2403,6 +2405,7 @@ impl AcpThreadView {
|
||||
.into_any_element()
|
||||
}
|
||||
|
||||
#[ztracing::instrument(skip_all)]
|
||||
fn render_tool_call(
|
||||
&self,
|
||||
entry_ix: usize,
|
||||
@@ -2631,6 +2634,7 @@ impl AcpThreadView {
|
||||
.children(tool_output_display)
|
||||
}
|
||||
|
||||
#[ztracing::instrument(skip_all)]
|
||||
fn render_tool_call_label(
|
||||
&self,
|
||||
entry_ix: usize,
|
||||
@@ -2739,6 +2743,7 @@ impl AcpThreadView {
|
||||
.when(!is_edit, |this| this.child(gradient_overlay))
|
||||
}
|
||||
|
||||
#[ztracing::instrument(skip_all)]
|
||||
fn render_tool_call_content(
|
||||
&self,
|
||||
entry_ix: usize,
|
||||
@@ -2773,6 +2778,7 @@ impl AcpThreadView {
|
||||
}
|
||||
}
|
||||
|
||||
#[ztracing::instrument(skip_all)]
|
||||
fn render_markdown_output(
|
||||
&self,
|
||||
markdown: Entity<Markdown>,
|
||||
@@ -3037,6 +3043,7 @@ impl AcpThreadView {
|
||||
.into_any()
|
||||
}
|
||||
|
||||
#[ztracing::instrument(skip_all)]
|
||||
fn render_terminal_tool_call(
|
||||
&self,
|
||||
entry_ix: usize,
|
||||
@@ -3724,6 +3731,7 @@ impl AcpThreadView {
|
||||
editor_bg_color.blend(active_color.opacity(0.3))
|
||||
}
|
||||
|
||||
#[ztracing::instrument(skip_all)]
|
||||
fn render_activity_bar(
|
||||
&self,
|
||||
thread_entity: &Entity<AcpThread>,
|
||||
@@ -3791,6 +3799,7 @@ impl AcpThreadView {
|
||||
.into()
|
||||
}
|
||||
|
||||
#[ztracing::instrument(skip_all)]
|
||||
fn render_plan_summary(
|
||||
&self,
|
||||
plan: &Plan,
|
||||
@@ -3886,6 +3895,7 @@ impl AcpThreadView {
|
||||
}))
|
||||
}
|
||||
|
||||
#[ztracing::instrument(skip_all)]
|
||||
fn render_plan_entries(
|
||||
&self,
|
||||
plan: &Plan,
|
||||
@@ -3946,6 +3956,7 @@ impl AcpThreadView {
|
||||
.into_any_element()
|
||||
}
|
||||
|
||||
#[ztracing::instrument(skip_all)]
|
||||
fn render_edits_summary(
|
||||
&self,
|
||||
changed_buffers: &BTreeMap<Entity<Buffer>, Entity<BufferDiff>>,
|
||||
@@ -4074,6 +4085,7 @@ impl AcpThreadView {
|
||||
)
|
||||
}
|
||||
|
||||
#[ztracing::instrument(skip_all)]
|
||||
fn render_edited_files(
|
||||
&self,
|
||||
action_log: &Entity<ActionLog>,
|
||||
@@ -4711,6 +4723,7 @@ impl AcpThreadView {
|
||||
}))
|
||||
}
|
||||
|
||||
#[ztracing::instrument(skip_all)]
|
||||
fn render_markdown(&self, markdown: Entity<Markdown>, style: MarkdownStyle) -> MarkdownElement {
|
||||
let workspace = self.workspace.clone();
|
||||
MarkdownElement::new(markdown, style).on_url_click(move |text, window, cx| {
|
||||
@@ -5992,6 +6005,7 @@ impl Focusable for AcpThreadView {
|
||||
}
|
||||
|
||||
impl Render for AcpThreadView {
|
||||
#[ztracing::instrument(skip_all)]
|
||||
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
let has_messages = self.list_state.item_count() > 0;
|
||||
let line_height = TextSize::Small.rems(cx).to_pixels(window.rem_size()) * 1.5;
|
||||
|
||||
@@ -1757,6 +1757,7 @@ impl AgentPanel {
|
||||
});
|
||||
}
|
||||
|
||||
#[ztracing::instrument(skip_all)]
|
||||
fn render_panel_options_menu(
|
||||
&self,
|
||||
window: &mut Window,
|
||||
@@ -2563,6 +2564,7 @@ impl AgentPanel {
|
||||
}
|
||||
}
|
||||
|
||||
#[ztracing::instrument(skip_all)]
|
||||
fn render_text_thread(
|
||||
&self,
|
||||
text_thread_editor: &Entity<TextThreadEditor>,
|
||||
@@ -2737,6 +2739,7 @@ impl AgentPanel {
|
||||
}
|
||||
|
||||
impl Render for AgentPanel {
|
||||
#[ztracing::instrument(skip_all)]
|
||||
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
// WARNING: Changes to this element hierarchy can have
|
||||
// non-obvious implications to the layout of children.
|
||||
|
||||
@@ -2651,6 +2651,7 @@ impl EventEmitter<EditorEvent> for TextThreadEditor {}
|
||||
impl EventEmitter<SearchEvent> for TextThreadEditor {}
|
||||
|
||||
impl Render for TextThreadEditor {
|
||||
#[ztracing::instrument(skip_all)]
|
||||
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
let language_model_selector = self.language_model_selector_menu_handle.clone();
|
||||
|
||||
|
||||
@@ -29,8 +29,10 @@ log.workspace = true
|
||||
pulldown-cmark.workspace = true
|
||||
sum_tree.workspace = true
|
||||
theme.workspace = true
|
||||
tracing.workspace = true
|
||||
ui.workspace = true
|
||||
util.workspace = true
|
||||
ztracing.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
assets.workspace = true
|
||||
@@ -41,3 +43,6 @@ languages = { workspace = true, features = ["load-grammars"] }
|
||||
node_runtime.workspace = true
|
||||
settings = { workspace = true, features = ["test-support"] }
|
||||
util = { workspace = true, features = ["test-support"] }
|
||||
|
||||
[package.metadata.cargo-machete]
|
||||
ignored = ["tracing"]
|
||||
@@ -831,6 +831,7 @@ impl Element for MarkdownElement {
|
||||
None
|
||||
}
|
||||
|
||||
#[ztracing::instrument(skip_all)]
|
||||
fn request_layout(
|
||||
&mut self,
|
||||
_id: Option<&GlobalElementId>,
|
||||
@@ -1324,6 +1325,7 @@ impl Element for MarkdownElement {
|
||||
(layout_id, rendered_markdown)
|
||||
}
|
||||
|
||||
#[ztracing::instrument(skip_all)]
|
||||
fn prepaint(
|
||||
&mut self,
|
||||
_id: Option<&GlobalElementId>,
|
||||
@@ -1343,6 +1345,7 @@ impl Element for MarkdownElement {
|
||||
hitbox
|
||||
}
|
||||
|
||||
#[ztracing::instrument(skip_all)]
|
||||
fn paint(
|
||||
&mut self,
|
||||
_id: Option<&GlobalElementId>,
|
||||
|
||||
@@ -159,6 +159,7 @@ vim_mode_setting.workspace = true
|
||||
watch.workspace = true
|
||||
web_search.workspace = true
|
||||
web_search_providers.workspace = true
|
||||
which.workspace = true
|
||||
which_key.workspace = true
|
||||
workspace.workspace = true
|
||||
zed_actions.workspace = true
|
||||
|
||||
@@ -139,6 +139,10 @@ actions!(
|
||||
/// audio system (including yourself) on the current call in a tar file
|
||||
/// in the current working directory.
|
||||
CaptureRecentAudio,
|
||||
/// Starts Tracy profiling by launching tracy-profiler if available.
|
||||
/// Tracy will connect to this Zed instance and begin capturing performance data.
|
||||
/// Requires Zed to be built with tracy support (ZTRACING=1).
|
||||
StartTracing,
|
||||
]
|
||||
);
|
||||
|
||||
@@ -1148,6 +1152,9 @@ fn register_actions(
|
||||
})
|
||||
.register_action(|workspace, _: &CaptureRecentAudio, window, cx| {
|
||||
capture_recent_audio(workspace, window, cx);
|
||||
})
|
||||
.register_action(|workspace, _: &StartTracing, window, cx| {
|
||||
start_tracing(workspace, window, cx);
|
||||
});
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
@@ -2211,6 +2218,117 @@ fn capture_recent_audio(workspace: &mut Workspace, _: &mut Window, cx: &mut Cont
|
||||
);
|
||||
}
|
||||
|
||||
fn start_tracing(workspace: &mut Workspace, _window: &mut Window, cx: &mut Context<Workspace>) {
|
||||
struct StartTracingNotification {
|
||||
focus_handle: gpui::FocusHandle,
|
||||
status: TracingStatus,
|
||||
_spawn_task: Option<Task<()>>,
|
||||
}
|
||||
|
||||
enum TracingStatus {
|
||||
Starting,
|
||||
TracyLaunched,
|
||||
TracyNotFound,
|
||||
TracyLaunchFailed(String),
|
||||
ZtracingNotEnabled,
|
||||
}
|
||||
|
||||
impl gpui::EventEmitter<DismissEvent> for StartTracingNotification {}
|
||||
impl gpui::EventEmitter<SuppressEvent> for StartTracingNotification {}
|
||||
impl gpui::Focusable for StartTracingNotification {
|
||||
fn focus_handle(&self, _cx: &App) -> gpui::FocusHandle {
|
||||
self.focus_handle.clone()
|
||||
}
|
||||
}
|
||||
impl workspace::notifications::Notification for StartTracingNotification {}
|
||||
|
||||
impl Render for StartTracingNotification {
|
||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
let (title, message) = match &self.status {
|
||||
TracingStatus::Starting => (
|
||||
"Starting Tracy",
|
||||
"Launching tracy-profiler...".to_string(),
|
||||
),
|
||||
TracingStatus::TracyLaunched => (
|
||||
"Tracy Profiler Ready",
|
||||
"Tracy profiler has been launched. It should automatically connect to this Zed instance and begin capturing performance data.".to_string(),
|
||||
),
|
||||
TracingStatus::TracyNotFound => (
|
||||
"Tracy Not Found",
|
||||
"Could not find `tracy-profiler` on your PATH. Please install Tracy profiler and ensure it's available in your PATH.\n\nOn macOS: brew install tracy\nOn Linux: Install from your package manager or build from source".to_string(),
|
||||
),
|
||||
TracingStatus::TracyLaunchFailed(error) => (
|
||||
"Tracy Launch Failed",
|
||||
format!("Failed to launch tracy-profiler: {}", error),
|
||||
),
|
||||
TracingStatus::ZtracingNotEnabled => (
|
||||
"Tracy Support Not Enabled",
|
||||
"This build of Zed was not compiled with Tracy support. To enable tracing, rebuild Zed with `cargo build --features tracy`.".to_string(),
|
||||
),
|
||||
};
|
||||
|
||||
let show_debug_warning =
|
||||
cfg!(debug_assertions) && matches!(self.status, TracingStatus::TracyLaunched);
|
||||
|
||||
NotificationFrame::new()
|
||||
.with_title(Some(title))
|
||||
.show_suppress_button(false)
|
||||
.on_close(cx.listener(|_, _, _, cx| {
|
||||
cx.emit(DismissEvent);
|
||||
}))
|
||||
.with_content(message)
|
||||
}
|
||||
}
|
||||
|
||||
impl StartTracingNotification {
|
||||
fn new(cx: &mut Context<Self>) -> Self {
|
||||
if !ztracing::is_enabled() {
|
||||
return Self {
|
||||
focus_handle: cx.focus_handle(),
|
||||
status: TracingStatus::ZtracingNotEnabled,
|
||||
_spawn_task: None,
|
||||
};
|
||||
}
|
||||
|
||||
let spawn_task = cx.spawn(async move |this, cx| {
|
||||
let tracy_path = cx
|
||||
.background_spawn(async { which::which("tracy-profiler").ok() })
|
||||
.await;
|
||||
|
||||
let status = match tracy_path {
|
||||
Some(path) => {
|
||||
let spawn_result = smol::process::Command::new(&path).spawn();
|
||||
|
||||
match spawn_result {
|
||||
Ok(_child) => TracingStatus::TracyLaunched,
|
||||
Err(error) => TracingStatus::TracyLaunchFailed(error.to_string()),
|
||||
}
|
||||
}
|
||||
None => TracingStatus::TracyNotFound,
|
||||
};
|
||||
|
||||
this.update(cx, |this, cx| {
|
||||
this.status = status;
|
||||
cx.notify();
|
||||
})
|
||||
.ok();
|
||||
});
|
||||
|
||||
Self {
|
||||
focus_handle: cx.focus_handle(),
|
||||
status: TracingStatus::Starting,
|
||||
_spawn_task: Some(spawn_task),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
workspace.show_notification(
|
||||
NotificationId::unique::<StartTracingNotification>(),
|
||||
cx,
|
||||
|cx| cx.new(StartTracingNotification::new),
|
||||
);
|
||||
}
|
||||
|
||||
/// Eagerly loads the active theme and icon theme based on the selections in the
|
||||
/// theme settings.
|
||||
///
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
use std::env;
|
||||
|
||||
fn main() {
|
||||
if env::var_os("ZTRACING").is_some() {
|
||||
println!(r"cargo::rustc-cfg=ztracing");
|
||||
}
|
||||
println!("cargo::rerun-if-changed=build.rs");
|
||||
println!("cargo::rerun-if-env-changed=ZTRACING");
|
||||
}
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
pub use tracing::{Level, field};
|
||||
|
||||
#[cfg(ztracing)]
|
||||
#[cfg(feature = "tracy")]
|
||||
pub use tracing::{
|
||||
Span, debug_span, error_span, event, info_span, instrument, span, trace_span, warn_span,
|
||||
};
|
||||
#[cfg(not(ztracing))]
|
||||
#[cfg(not(feature = "tracy"))]
|
||||
pub use ztracing_macro::instrument;
|
||||
|
||||
#[cfg(not(ztracing))]
|
||||
#[cfg(not(feature = "tracy"))]
|
||||
pub use __consume_all_tokens as trace_span;
|
||||
#[cfg(not(ztracing))]
|
||||
#[cfg(not(feature = "tracy"))]
|
||||
pub use __consume_all_tokens as info_span;
|
||||
#[cfg(not(ztracing))]
|
||||
#[cfg(not(feature = "tracy"))]
|
||||
pub use __consume_all_tokens as debug_span;
|
||||
#[cfg(not(ztracing))]
|
||||
#[cfg(not(feature = "tracy"))]
|
||||
pub use __consume_all_tokens as warn_span;
|
||||
#[cfg(not(ztracing))]
|
||||
#[cfg(not(feature = "tracy"))]
|
||||
pub use __consume_all_tokens as error_span;
|
||||
#[cfg(not(ztracing))]
|
||||
#[cfg(not(feature = "tracy"))]
|
||||
pub use __consume_all_tokens as event;
|
||||
#[cfg(not(ztracing))]
|
||||
#[cfg(not(feature = "tracy"))]
|
||||
pub use __consume_all_tokens as span;
|
||||
|
||||
#[cfg(not(ztracing))]
|
||||
#[cfg(not(feature = "tracy"))]
|
||||
#[macro_export]
|
||||
macro_rules! __consume_all_tokens {
|
||||
($($t:tt)*) => {
|
||||
@@ -30,10 +30,10 @@ macro_rules! __consume_all_tokens {
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(not(ztracing))]
|
||||
#[cfg(not(feature = "tracy"))]
|
||||
pub struct Span;
|
||||
|
||||
#[cfg(not(ztracing))]
|
||||
#[cfg(not(feature = "tracy"))]
|
||||
impl Span {
|
||||
pub fn current() -> Self {
|
||||
Self
|
||||
@@ -44,7 +44,7 @@ impl Span {
|
||||
pub fn record<T, S>(&self, _t: T, _s: S) {}
|
||||
}
|
||||
|
||||
#[cfg(ztracing)]
|
||||
#[cfg(feature = "tracy")]
|
||||
pub fn init() {
|
||||
zlog::info!("Starting tracy subscriber, you can now connect the profiler");
|
||||
use tracing_subscriber::prelude::*;
|
||||
@@ -54,5 +54,23 @@ pub fn init() {
|
||||
.expect("setup tracy layer");
|
||||
}
|
||||
|
||||
#[cfg(not(ztracing))]
|
||||
#[cfg(not(feature = "tracy"))]
|
||||
pub fn init() {}
|
||||
|
||||
/// Returns true if this build was compiled with Tracy profiling support.
|
||||
///
|
||||
/// When true, `init()` will set up the Tracy subscriber and the application
|
||||
/// can be profiled by connecting Tracy profiler to it.
|
||||
#[cfg(feature = "tracy")]
|
||||
pub const fn is_enabled() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
/// Returns true if this build was compiled with Tracy profiling support.
|
||||
///
|
||||
/// When true, `init()` will set up the Tracy subscriber and the application
|
||||
/// can be profiled by connecting Tracy profiler to it.
|
||||
#[cfg(not(feature = "tracy"))]
|
||||
pub const fn is_enabled() -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user