From 6995e60ee159f3a0c7c6cacbdb7961fe23f68877 Mon Sep 17 00:00:00 2001 From: Shubham Gupta <32428749+shubhamg13@users.noreply.github.com> Date: Tue, 30 Sep 2025 19:07:35 +0800 Subject: [PATCH] compositor: Add Paint Metric events to Perfetto Traces (#39502) > Some metrics like TimeToFirstPaint and TimeToFirstContentfulPaint are only in the HTML traces. [See this](https://github.com/servo/perf-analysis-tools?tab=readme-ov-file#how-to-analyse-a-single-servo-sample) In order to analyse the performance and refine [perf-analysis-tools](https://github.com/servo/perf-analysis-tools) we need these metrics to be added to Perfetto also. Screenshot from 2025-09-26 15-00-00 Screenshot from 2025-09-26 15-00-42 Testing: Verified by using Perfetto traces Signed-off-by: Shubham Gupta --- components/compositing/compositor.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 12c80f29be1..fb67ca41a2c 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -1383,6 +1383,14 @@ impl IOCompositor { // the first "real" display list. PaintMetricState::Seen(epoch, first_reflow) if epoch <= current_epoch => { assert!(epoch <= current_epoch); + #[cfg(feature = "tracing")] + tracing::info!( + name: "FirstPaint", + servo_profiling = true, + epoch = ?epoch, + paint_time = ?paint_time, + pipeline_id = ?pipeline_id, + ); if let Err(error) = self.global.borrow().constellation_sender.send( EmbedderToConstellationMessage::PaintMetric( *pipeline_id, @@ -1400,6 +1408,14 @@ impl IOCompositor { match pipeline.first_contentful_paint_metric { PaintMetricState::Seen(epoch, first_reflow) if epoch <= current_epoch => { + #[cfg(feature = "tracing")] + tracing::info!( + name: "FirstContentfulPaint", + servo_profiling = true, + epoch = ?epoch, + paint_time = ?paint_time, + pipeline_id = ?pipeline_id, + ); if let Err(error) = self.global.borrow().constellation_sender.send( EmbedderToConstellationMessage::PaintMetric( *pipeline_id,