aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDelan Azabani <dazabani@igalia.com>2024-11-25 20:17:11 +0800
committerDelan Azabani <delan@azabani.com>2024-12-11 13:36:18 +0800
commitc25e4d37254e89642e91585cda1f231b34c47241 (patch)
treef67725ba0d34afb16d9b0ac3b240c0e24067aff9
parent16f5767706aa51315725213fe4863d3e1b4ae98a (diff)
downloadservo-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>
-rw-r--r--Cargo.lock2
-rw-r--r--components/metrics/Cargo.toml4
-rw-r--r--components/metrics/lib.rs37
-rw-r--r--components/script/dom/document.rs10
-rw-r--r--components/script/script_thread.rs4
-rw-r--r--components/servo/Cargo.toml3
6 files changed, 48 insertions, 12 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 04f3954b95f..6074fb1e9b0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4009,6 +4009,7 @@ dependencies = [
"layout_thread_2020",
"log",
"media",
+ "metrics",
"mozangle",
"net",
"net_traits",
@@ -4290,6 +4291,7 @@ dependencies = [
"script_traits",
"servo_config",
"servo_url",
+ "tracing",
]
[[package]]
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,
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index babfffe9046..28b40109778 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -2607,6 +2607,12 @@ impl Document {
"Complete before DOMContentLoaded?"
);
+ // We only want a tracing event for DOMContentLoaded for actual pages and iframes,
+ // not when a script is just parsing a fragment.
+ if self.has_browsing_context() {
+ #[cfg(feature = "tracing")]
+ tracing::info!(name: "DOMContentLoaded", servo_profiling = true, url = self.url().to_string());
+ }
update_with_current_instant(&self.dom_content_loaded_event_start);
// Step 4.1.
@@ -2781,6 +2787,10 @@ impl Document {
return;
}
if self.tti_window.borrow().needs_check() {
+ // TODO(delan): include this in Perfetto traces. May require support for backdating
+ // events, unless we include all candidates and filter them in perf-analysis-tools.
+ // Not a high priority, since TTI is now considered to be an outdated metric:
+ // <https://developer.chrome.com/docs/lighthouse/performance/interactive/>
self.get_interactive_metrics().maybe_set_tti(
self,
InteractiveFlag::TimeToInteractive(self.tti_window.borrow().get_start()),
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index 648e3034f36..0f36d85dedc 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -238,6 +238,10 @@ impl InProgressLoad {
inherited_secure_context: Option<bool>,
) -> InProgressLoad {
let navigation_start = CrossProcessInstant::now();
+
+ #[cfg(feature = "tracing")]
+ tracing::info!(name: "Navigation start", servo_profiling = true, url = url.to_string());
+
InProgressLoad {
pipeline_id: id,
browsing_context_id,
diff --git a/components/servo/Cargo.toml b/components/servo/Cargo.toml
index 7db65516bc4..11d032e2053 100644
--- a/components/servo/Cargo.toml
+++ b/components/servo/Cargo.toml
@@ -24,7 +24,7 @@ no-wgl = ["mozangle/egl", "mozangle/build_dlls", "surfman/sm-angle-default"]
dynamic_freetype = ["webrender/dynamic_freetype"]
profilemozjs = ["script/profilemozjs"]
refcell_backtrace = ["script/refcell_backtrace"]
-tracing = ["dep:tracing", "compositing/tracing", "constellation/tracing", "layout_thread_2013/tracing", "layout_thread_2020/tracing", "profile_traits/tracing", "script/tracing"]
+tracing = ["dep:tracing", "compositing/tracing", "constellation/tracing", "layout_thread_2013/tracing", "layout_thread_2020/tracing", "metrics/tracing", "profile_traits/tracing", "script/tracing"]
webdriver = ["webdriver_server"]
webgl_backtrace = [
"script/webgl_backtrace",
@@ -59,6 +59,7 @@ layout_thread_2013 = { path = "../layout_thread", optional = true }
layout_thread_2020 = { path = "../layout_thread_2020" }
log = { workspace = true }
media = { path = "../media" }
+metrics = { path = "../metrics" }
mozangle = { workspace = true }
net = { path = "../net" }
net_traits = { workspace = true }