mirror of
https://github.com/servo/servo.git
synced 2025-07-09 16:33:40 +01:00
Auto merge of #19218 - avadacatavra:nav-start, r=jdm
added navigation start for interactive metrics <!-- Please describe your changes on the following line: --> follow up from #18670, fixing #19099 --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #19099 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19218) <!-- Reviewable:end -->
This commit is contained in:
commit
7d13e5b83c
3 changed files with 18 additions and 3 deletions
|
@ -40,6 +40,7 @@ pub trait ProgressiveWebMetric {
|
||||||
fn send_queued_constellation_msg(&self, name: ProgressiveWebMetricType, time: u64);
|
fn send_queued_constellation_msg(&self, name: ProgressiveWebMetricType, time: u64);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// TODO make this configurable
|
||||||
/// maximum task time is 50ms (in ns)
|
/// maximum task time is 50ms (in ns)
|
||||||
pub const MAX_TASK_NS: u64 = 50000000;
|
pub const MAX_TASK_NS: u64 = 50000000;
|
||||||
/// 10 second window (in ns)
|
/// 10 second window (in ns)
|
||||||
|
@ -84,6 +85,7 @@ fn set_metric<U: ProgressiveWebMetric>(
|
||||||
|
|
||||||
// Print the metric to console if the print-pwm option was given.
|
// Print the metric to console if the print-pwm option was given.
|
||||||
if opts::get().print_pwm {
|
if opts::get().print_pwm {
|
||||||
|
println!("Navigation start: {}", pwm.get_navigation_start().unwrap());
|
||||||
println!("{:?} {:?}", metric_type, time);
|
println!("{:?} {:?}", metric_type, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,6 +218,10 @@ impl InteractiveMetrics {
|
||||||
pub fn get_tti(&self) -> Option<u64> {
|
pub fn get_tti(&self) -> Option<u64> {
|
||||||
self.time_to_interactive.get()
|
self.time_to_interactive.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn needs_tti(&self) -> bool {
|
||||||
|
self.get_tti().is_none()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ProgressiveWebMetric for InteractiveMetrics {
|
impl ProgressiveWebMetric for InteractiveMetrics {
|
||||||
|
|
|
@ -97,7 +97,7 @@ use hyper_serde::Serde;
|
||||||
use ipc_channel::ipc::{self, IpcSender};
|
use ipc_channel::ipc::{self, IpcSender};
|
||||||
use js::jsapi::{JSContext, JSRuntime};
|
use js::jsapi::{JSContext, JSRuntime};
|
||||||
use js::jsapi::JS_GetRuntime;
|
use js::jsapi::JS_GetRuntime;
|
||||||
use metrics::{InteractiveFlag, InteractiveMetrics, InteractiveWindow, ProfilerMetadataFactory};
|
use metrics::{InteractiveFlag, InteractiveMetrics, InteractiveWindow, ProfilerMetadataFactory, ProgressiveWebMetric};
|
||||||
use msg::constellation_msg::{BrowsingContextId, Key, KeyModifiers, KeyState, TopLevelBrowsingContextId};
|
use msg::constellation_msg::{BrowsingContextId, Key, KeyModifiers, KeyState, TopLevelBrowsingContextId};
|
||||||
use net_traits::{FetchResponseMsg, IpcSend, ReferrerPolicy};
|
use net_traits::{FetchResponseMsg, IpcSend, ReferrerPolicy};
|
||||||
use net_traits::CookieSource::NonHTTP;
|
use net_traits::CookieSource::NonHTTP;
|
||||||
|
@ -1911,6 +1911,10 @@ impl Document {
|
||||||
self.dom_interactive.get()
|
self.dom_interactive.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_navigation_start(&self, navigation_start: u64) {
|
||||||
|
self.interactive_time.borrow_mut().set_navigation_start(navigation_start);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_interactive_metrics(&self) -> Ref<InteractiveMetrics> {
|
pub fn get_interactive_metrics(&self) -> Ref<InteractiveMetrics> {
|
||||||
self.interactive_time.borrow()
|
self.interactive_time.borrow()
|
||||||
}
|
}
|
||||||
|
@ -1940,15 +1944,16 @@ impl Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start_tti(&self) {
|
pub fn start_tti(&self) {
|
||||||
|
if self.get_interactive_metrics().needs_tti() {
|
||||||
self.tti_window.borrow_mut().start_window();
|
self.tti_window.borrow_mut().start_window();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// check tti for this document
|
/// check tti for this document
|
||||||
/// if it's been 10s since this doc encountered a task over 50ms, then we consider the
|
/// if it's been 10s since this doc encountered a task over 50ms, then we consider the
|
||||||
/// main thread available and try to set tti
|
/// main thread available and try to set tti
|
||||||
pub fn record_tti_if_necessary(&self) {
|
pub fn record_tti_if_necessary(&self) {
|
||||||
if self.has_recorded_tti_metric() { return; }
|
if self.has_recorded_tti_metric() { return; }
|
||||||
|
|
||||||
if self.tti_window.borrow().needs_check() {
|
if self.tti_window.borrow().needs_check() {
|
||||||
self.get_interactive_metrics().maybe_set_tti(self,
|
self.get_interactive_metrics().maybe_set_tti(self,
|
||||||
InteractiveFlag::TimeToInteractive(self.tti_window.borrow().get_start()));
|
InteractiveFlag::TimeToInteractive(self.tti_window.borrow().get_start()));
|
||||||
|
|
|
@ -1248,6 +1248,9 @@ impl ScriptThread {
|
||||||
for (doc_id, doc) in self.documents.borrow().iter() {
|
for (doc_id, doc) in self.documents.borrow().iter() {
|
||||||
if let Some(pipeline_id) = pipeline_id {
|
if let Some(pipeline_id) = pipeline_id {
|
||||||
if pipeline_id == doc_id && end - start > MAX_TASK_NS {
|
if pipeline_id == doc_id && end - start > MAX_TASK_NS {
|
||||||
|
if opts::get().print_pwm {
|
||||||
|
println!("Task took longer than max allowed ({:?}) {:?}", category, end - start);
|
||||||
|
}
|
||||||
doc.start_tti();
|
doc.start_tti();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2229,6 +2232,7 @@ impl ScriptThread {
|
||||||
let parse_input = DOMString::new();
|
let parse_input = DOMString::new();
|
||||||
|
|
||||||
document.set_https_state(metadata.https_state);
|
document.set_https_state(metadata.https_state);
|
||||||
|
document.set_navigation_start(incomplete.navigation_start_precise);
|
||||||
|
|
||||||
if is_html_document == IsHTMLDocument::NonHTMLDocument {
|
if is_html_document == IsHTMLDocument::NonHTMLDocument {
|
||||||
ServoParser::parse_xml_document(&document, parse_input, final_url);
|
ServoParser::parse_xml_document(&document, parse_input, final_url);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue