Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
linux: Add tracing logs to the x11 client and linux dispatcher (#13928)
Thorsten Ballcd7268f21f04
diff --git a/crates/gpui/src/platform/linux/dispatcher.rs b/crates/gpui/src/platform/linux/dispatcher.rsindex ad4628ed5d5..46da60999c0 100644--- a/crates/gpui/src/platform/linux/dispatcher.rs+++ b/crates/gpui/src/platform/linux/dispatcher.rs@@ -8,7 +8,11 @@ use calloop::{use mio::Waker;use parking::{Parker, Unparker};use parking_lot::Mutex;-use std::{sync::Arc, thread, time::Duration};+use std::{+ sync::Arc,+ thread,+ time::{Duration, Instant},+};use util::ResultExt;struct TimerAfter {@@ -34,11 +38,19 @@ impl LinuxDispatcher {.unwrap_or(1);let mut background_threads = (0..thread_count)- .map(|_| {+ .map(|i| {let receiver = background_receiver.clone();std::thread::spawn(move || {for runnable in receiver {+ let start = Instant::now();+runnable.run();++ log::trace!(+ "background thread {}: ran runnable. took: {:?}",+ i,+ start.elapsed()+ );}})})diff --git a/crates/gpui/src/platform/linux/x11/client.rs b/crates/gpui/src/platform/linux/x11/client.rsindex 11d2efb43b4..8590defea92 100644--- a/crates/gpui/src/platform/linux/x11/client.rs+++ b/crates/gpui/src/platform/linux/x11/client.rs@@ -462,7 +462,14 @@ impl X11Client {}fn process_x11_events(&self, events: Vec<Event>) {+ log::trace!(+ "main thread: processing X11 events. events: {}",+ events.len()+ );+for event in events.into_iter() {+ log::trace!("main thread: processing X11 event: {:?}", event);+let mut state = self.0.borrow_mut();if state.ximc.is_none() || state.xim_handler.is_none() {drop(state);@@ -1221,6 +1228,10 @@ impl LinuxClient for X11Client {let (x_windows, events) = self.read_x11_events();for x_window in x_windows {if let Some(window) = self.get_window(x_window) {+ log::trace!(+ "main thread: refreshing window {} due expose event",+ window.x_window+ );window.refresh();}}@@ -1242,7 +1253,13 @@ impl LinuxClient for X11Client {// Runnableswhile let Ok(runnable) = state.runnables.try_recv() {drop(state);++ let start = Instant::now();+runnable.run();++ log::trace!("main thread: ran runnable. took: {:?}", start.elapsed());+state = self.0.borrow_mut();if Instant::now() + Duration::from_millis(1) >= next_refresh_needed {@@ -1252,6 +1269,7 @@ impl LinuxClient for X11Client {// XDG eventsif let Ok(event) = state.xdp_event_source.try_recv() {+ log::trace!("main thread: XDG event");match event {XDPEvent::WindowAppearance(appearance) => {let mut windows = state