From bb0529d300b3dd64034f7af85a2579638f436b42 Mon Sep 17 00:00:00 2001 From: Jonathan Schwender <55576758+jschwe@users.noreply.github.com> Date: Mon, 9 Dec 2024 16:47:24 +0100 Subject: [PATCH] tracing: Trace Constellation blocked duration (#34536) Add a trace for the `select!` macro, so that we can easily identify the amount of time we are blocked in the trace A different option might be to just skip tracing the `handle_request` function entirely, since it contains almost nothing interesting. Signed-off-by: Jonathan Schwender --- components/constellation/constellation.rs | 67 ++++++++++++----------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index db48eaaff89..630de904fbb 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -1206,38 +1206,43 @@ where // produces undefined behaviour, resulting in the destructor // being called. If this happens, there's not much we can do // other than panic. - let request = select! { - recv(self.namespace_receiver) -> msg => { - msg.expect("Unexpected script channel panic in constellation").map(Request::PipelineNamespace) + let request = { + #[cfg(feature = "tracing")] + let _span = + tracing::trace_span!("handle_request::select", servo_profiling = true).entered(); + select! { + recv(self.namespace_receiver) -> msg => { + msg.expect("Unexpected script channel panic in constellation").map(Request::PipelineNamespace) + } + recv(self.script_receiver) -> msg => { + msg.expect("Unexpected script channel panic in constellation").map(Request::Script) + } + recv(self.background_hang_monitor_receiver) -> msg => { + msg.expect("Unexpected BHM channel panic in constellation").map(Request::BackgroundHangMonitor) + } + recv(self.compositor_receiver) -> msg => { + Ok(Request::Compositor(msg.expect("Unexpected compositor channel panic in constellation"))) + } + recv(self.layout_receiver) -> msg => { + msg.expect("Unexpected layout channel panic in constellation").map(Request::Layout) + } + recv(self.network_listener_receiver) -> msg => { + Ok(Request::NetworkListener( + msg.expect("Unexpected network listener channel panic in constellation") + )) + } + recv(self.swmanager_receiver) -> msg => { + msg.expect("Unexpected SW channel panic in constellation").map(Request::FromSWManager) + } + recv(self.scheduler_receiver) -> msg => { + msg.expect("Unexpected schedule channel panic in constellation").map(Request::Timer) + } + recv(scheduler_timeout) -> _ => { + // Note: by returning, we go back to the top, + // where check_timers will be called. + return; + }, } - recv(self.script_receiver) -> msg => { - msg.expect("Unexpected script channel panic in constellation").map(Request::Script) - } - recv(self.background_hang_monitor_receiver) -> msg => { - msg.expect("Unexpected BHM channel panic in constellation").map(Request::BackgroundHangMonitor) - } - recv(self.compositor_receiver) -> msg => { - Ok(Request::Compositor(msg.expect("Unexpected compositor channel panic in constellation"))) - } - recv(self.layout_receiver) -> msg => { - msg.expect("Unexpected layout channel panic in constellation").map(Request::Layout) - } - recv(self.network_listener_receiver) -> msg => { - Ok(Request::NetworkListener( - msg.expect("Unexpected network listener channel panic in constellation") - )) - } - recv(self.swmanager_receiver) -> msg => { - msg.expect("Unexpected SW channel panic in constellation").map(Request::FromSWManager) - } - recv(self.scheduler_receiver) -> msg => { - msg.expect("Unexpected schedule channel panic in constellation").map(Request::Timer) - } - recv(scheduler_timeout) -> _ => { - // Note: by returning, we go back to the top, - // where check_timers will be called. - return; - }, }; let request = match request {