diff options
author | Delan Azabani <dazabani@igalia.com> | 2024-11-25 20:17:11 +0800 |
---|---|---|
committer | Delan Azabani <delan@azabani.com> | 2024-12-11 13:36:18 +0800 |
commit | c25e4d37254e89642e91585cda1f231b34c47241 (patch) | |
tree | f67725ba0d34afb16d9b0ac3b240c0e24067aff9 /components/metrics | |
parent | 16f5767706aa51315725213fe4863d3e1b4ae98a (diff) | |
download | servo-as-of-2024-08-12.tar.gz servo-as-of-2024-08-12.zip |
Add tracing for navigation start, FP, FCP, and DOMContentLoaded (#34373)as-of-2024-08-12
Signed-off-by: Delan Azabani <dazabani@igalia.com>
Diffstat (limited to 'components/metrics')
-rw-r--r-- | components/metrics/Cargo.toml | 4 | ||||
-rw-r--r-- | components/metrics/lib.rs | 37 |
2 files changed, 30 insertions, 11 deletions
diff --git a/components/metrics/Cargo.toml b/components/metrics/Cargo.toml index f2464ccf24b..7f12c50ccf4 100644 --- a/components/metrics/Cargo.toml +++ b/components/metrics/Cargo.toml @@ -10,6 +10,9 @@ publish.workspace = true name = "metrics" path = "lib.rs" +[features] +tracing = ["dep:tracing"] + [dependencies] base = { workspace = true } fonts_traits = { workspace = true } @@ -21,3 +24,4 @@ profile_traits = { workspace = true } script_traits = { workspace = true } servo_config = { path = "../config" } servo_url = { path = "../url" } +tracing = { workspace = true, optional = true } diff --git a/components/metrics/lib.rs b/components/metrics/lib.rs index 0ac3021c52b..8c19b129209 100644 --- a/components/metrics/lib.rs +++ b/components/metrics/lib.rs @@ -322,17 +322,32 @@ impl PaintTimeMetrics { if let Some(pending_metric) = self.pending_metrics.borrow_mut().remove(&epoch) { let profiler_metadata = pending_metric.0; - set_metric( - self, - profiler_metadata.clone(), - ProgressiveWebMetricType::FirstPaint, - ProfilerCategory::TimeToFirstPaint, - &self.first_paint, - paint_time, - &self.url, - ); - - if pending_metric.1 { + + if self.first_paint.get().is_none() { + // TODO(delan): exclude compositor-to-script IPC time. May require support for + // backdating events, unless we make the compositor aware of things like the page + // URL for each pipeline and whether the paint was contentful. + #[cfg(feature = "tracing")] + tracing::info!(name: "First Paint", servo_profiling = true, url = self.url.to_string()); + + set_metric( + self, + profiler_metadata.clone(), + ProgressiveWebMetricType::FirstPaint, + ProfilerCategory::TimeToFirstPaint, + &self.first_paint, + paint_time, + &self.url, + ); + } + + if self.first_contentful_paint.get().is_none() && pending_metric.1 { + // TODO(delan): exclude compositor-to-script IPC time. May require support for + // backdating events, unless we make the compositor aware of things like the page + // URL for each pipeline and whether the paint was contentful. + #[cfg(feature = "tracing")] + tracing::info!(name: "First Contentful Paint", servo_profiling = true, url = self.url.to_string()); + set_metric( self, profiler_metadata, |