mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Auto merge of #21672 - kingdido999:master, r=jdm
Format components metrics and msg #21373 ```bash rustfmt components/metrics/lib.rs rustfmt components/msg/*.rs rustfmt components/msg/tests/*.rs ``` <!-- 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/21672) <!-- Reviewable:end -->
This commit is contained in:
commit
8c3b192466
4 changed files with 76 additions and 40 deletions
|
@ -64,14 +64,14 @@ fn set_metric<U: ProgressiveWebMetric>(
|
||||||
category: ProfilerCategory,
|
category: ProfilerCategory,
|
||||||
attr: &Cell<Option<u64>>,
|
attr: &Cell<Option<u64>>,
|
||||||
metric_time: Option<u64>,
|
metric_time: Option<u64>,
|
||||||
url: &ServoUrl)
|
url: &ServoUrl,
|
||||||
{
|
) {
|
||||||
let navigation_start = match pwm.get_navigation_start() {
|
let navigation_start = match pwm.get_navigation_start() {
|
||||||
Some(time) => time,
|
Some(time) => time,
|
||||||
None => {
|
None => {
|
||||||
warn!("Trying to set metric before navigation start");
|
warn!("Trying to set metric before navigation start");
|
||||||
return;
|
return;
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
let now = match metric_time {
|
let now = match metric_time {
|
||||||
Some(time) => time,
|
Some(time) => time,
|
||||||
|
@ -96,10 +96,12 @@ 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().to_ms());
|
println!(
|
||||||
|
"Navigation start: {}",
|
||||||
|
pwm.get_navigation_start().unwrap().to_ms()
|
||||||
|
);
|
||||||
println!("{:?} {:?} {:?}", url, metric_type, time.to_ms());
|
println!("{:?} {:?} {:?}", url, metric_type, time.to_ms());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// spec: https://github.com/WICG/time-to-interactive
|
// spec: https://github.com/WICG/time-to-interactive
|
||||||
|
@ -120,7 +122,7 @@ pub struct InteractiveMetrics {
|
||||||
time_to_interactive: Cell<Option<u64>>,
|
time_to_interactive: Cell<Option<u64>>,
|
||||||
#[ignore_malloc_size_of = "can't measure channels"]
|
#[ignore_malloc_size_of = "can't measure channels"]
|
||||||
time_profiler_chan: ProfilerChan,
|
time_profiler_chan: ProfilerChan,
|
||||||
url: ServoUrl
|
url: ServoUrl,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, MallocSizeOf)]
|
#[derive(Clone, Copy, Debug, MallocSizeOf)]
|
||||||
|
@ -128,7 +130,6 @@ pub struct InteractiveWindow {
|
||||||
start: u64,
|
start: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl InteractiveWindow {
|
impl InteractiveWindow {
|
||||||
pub fn new() -> InteractiveWindow {
|
pub fn new() -> InteractiveWindow {
|
||||||
InteractiveWindow {
|
InteractiveWindow {
|
||||||
|
@ -194,11 +195,8 @@ impl InteractiveMetrics {
|
||||||
|
|
||||||
// can set either dlc or tti first, but both must be set to actually calc metric
|
// can set either dlc or tti first, but both must be set to actually calc metric
|
||||||
// when the second is set, set_tti is called with appropriate time
|
// when the second is set, set_tti is called with appropriate time
|
||||||
pub fn maybe_set_tti<T>(
|
pub fn maybe_set_tti<T>(&self, profiler_metadata_factory: &T, metric: InteractiveFlag)
|
||||||
&self,
|
where
|
||||||
profiler_metadata_factory: &T,
|
|
||||||
metric: InteractiveFlag,
|
|
||||||
) where
|
|
||||||
T: ProfilerMetadataFactory,
|
T: ProfilerMetadataFactory,
|
||||||
{
|
{
|
||||||
if self.get_tti().is_some() {
|
if self.get_tti().is_some() {
|
||||||
|
@ -212,7 +210,7 @@ impl InteractiveMetrics {
|
||||||
let dcl = self.dom_content_loaded.get();
|
let dcl = self.dom_content_loaded.get();
|
||||||
let mta = self.main_thread_available.get();
|
let mta = self.main_thread_available.get();
|
||||||
let (dcl, mta) = match (dcl, mta) {
|
let (dcl, mta) = match (dcl, mta) {
|
||||||
(Some(dcl), Some(mta)) => (dcl, mta),
|
(Some(dcl), Some(mta)) => (dcl, mta),
|
||||||
_ => return,
|
_ => return,
|
||||||
};
|
};
|
||||||
let metric_time = match dcl.partial_cmp(&mta) {
|
let metric_time = match dcl.partial_cmp(&mta) {
|
||||||
|
@ -249,7 +247,7 @@ impl ProgressiveWebMetric for InteractiveMetrics {
|
||||||
self.navigation_start = Some(time);
|
self.navigation_start = Some(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_queued_constellation_msg(&self, _name: ProgressiveWebMetricType, _time: u64) { }
|
fn send_queued_constellation_msg(&self, _name: ProgressiveWebMetricType, _time: u64) {}
|
||||||
|
|
||||||
fn get_time_profiler_chan(&self) -> &ProfilerChan {
|
fn get_time_profiler_chan(&self) -> &ProfilerChan {
|
||||||
&self.time_profiler_chan
|
&self.time_profiler_chan
|
||||||
|
@ -279,8 +277,8 @@ impl PaintTimeMetrics {
|
||||||
time_profiler_chan: ProfilerChan,
|
time_profiler_chan: ProfilerChan,
|
||||||
constellation_chan: IpcSender<LayoutMsg>,
|
constellation_chan: IpcSender<LayoutMsg>,
|
||||||
script_chan: IpcSender<ConstellationControlMsg>,
|
script_chan: IpcSender<ConstellationControlMsg>,
|
||||||
url: ServoUrl)
|
url: ServoUrl,
|
||||||
-> PaintTimeMetrics {
|
) -> PaintTimeMetrics {
|
||||||
PaintTimeMetrics {
|
PaintTimeMetrics {
|
||||||
pending_metrics: RefCell::new(HashMap::new()),
|
pending_metrics: RefCell::new(HashMap::new()),
|
||||||
navigation_start: None,
|
navigation_start: None,
|
||||||
|
@ -317,17 +315,22 @@ impl PaintTimeMetrics {
|
||||||
&self,
|
&self,
|
||||||
profiler_metadata_factory: &T,
|
profiler_metadata_factory: &T,
|
||||||
epoch: Epoch,
|
epoch: Epoch,
|
||||||
display_list: &DisplayList)
|
display_list: &DisplayList,
|
||||||
where T: ProfilerMetadataFactory {
|
) where
|
||||||
|
T: ProfilerMetadataFactory,
|
||||||
|
{
|
||||||
if self.first_paint.get().is_some() && self.first_contentful_paint.get().is_some() {
|
if self.first_paint.get().is_some() && self.first_contentful_paint.get().is_some() {
|
||||||
// If we already set all paint metrics, we just bail out.
|
// If we already set all paint metrics, we just bail out.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.pending_metrics.borrow_mut().insert(epoch, (
|
self.pending_metrics.borrow_mut().insert(
|
||||||
profiler_metadata_factory.new_metadata(),
|
epoch,
|
||||||
display_list.is_contentful(),
|
(
|
||||||
));
|
profiler_metadata_factory.new_metadata(),
|
||||||
|
display_list.is_contentful(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
// Send the pending metric information to the compositor thread.
|
// Send the pending metric information to the compositor thread.
|
||||||
// The compositor will record the current time after painting the
|
// The compositor will record the current time after painting the
|
||||||
|
@ -340,7 +343,8 @@ impl PaintTimeMetrics {
|
||||||
|
|
||||||
pub fn maybe_set_metric(&self, epoch: Epoch, paint_time: u64) {
|
pub fn maybe_set_metric(&self, epoch: Epoch, paint_time: u64) {
|
||||||
if self.first_paint.get().is_some() && self.first_contentful_paint.get().is_some() ||
|
if self.first_paint.get().is_some() && self.first_contentful_paint.get().is_some() ||
|
||||||
self.navigation_start.is_none() {
|
self.navigation_start.is_none()
|
||||||
|
{
|
||||||
// If we already set all paint metrics or we have not set navigation start yet,
|
// If we already set all paint metrics or we have not set navigation start yet,
|
||||||
// we just bail out.
|
// we just bail out.
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -224,17 +224,21 @@ impl PipelineNamespace {
|
||||||
|
|
||||||
thread_local!(pub static PIPELINE_NAMESPACE: Cell<Option<PipelineNamespace>> = Cell::new(None));
|
thread_local!(pub static PIPELINE_NAMESPACE: Cell<Option<PipelineNamespace>> = Cell::new(None));
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd, Serialize)]
|
#[derive(
|
||||||
|
Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd, Serialize,
|
||||||
|
)]
|
||||||
pub struct PipelineNamespaceId(pub u32);
|
pub struct PipelineNamespaceId(pub u32);
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
|
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
|
||||||
pub struct PipelineIndex(pub NonZeroU32);
|
pub struct PipelineIndex(pub NonZeroU32);
|
||||||
malloc_size_of_is_0!(PipelineIndex);
|
malloc_size_of_is_0!(PipelineIndex);
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd, Serialize)]
|
#[derive(
|
||||||
|
Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd, Serialize,
|
||||||
|
)]
|
||||||
pub struct PipelineId {
|
pub struct PipelineId {
|
||||||
pub namespace_id: PipelineNamespaceId,
|
pub namespace_id: PipelineNamespaceId,
|
||||||
pub index: PipelineIndex
|
pub index: PipelineIndex,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PipelineId {
|
impl PipelineId {
|
||||||
|
@ -289,7 +293,9 @@ impl fmt::Display for PipelineId {
|
||||||
pub struct BrowsingContextIndex(pub NonZeroU32);
|
pub struct BrowsingContextIndex(pub NonZeroU32);
|
||||||
malloc_size_of_is_0!(BrowsingContextIndex);
|
malloc_size_of_is_0!(BrowsingContextIndex);
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd, Serialize)]
|
#[derive(
|
||||||
|
Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd, Serialize,
|
||||||
|
)]
|
||||||
pub struct BrowsingContextId {
|
pub struct BrowsingContextId {
|
||||||
pub namespace_id: PipelineNamespaceId,
|
pub namespace_id: PipelineNamespaceId,
|
||||||
pub index: BrowsingContextIndex,
|
pub index: BrowsingContextIndex,
|
||||||
|
@ -316,7 +322,9 @@ impl fmt::Display for BrowsingContextId {
|
||||||
|
|
||||||
thread_local!(pub static TOP_LEVEL_BROWSING_CONTEXT_ID: Cell<Option<TopLevelBrowsingContextId>> = Cell::new(None));
|
thread_local!(pub static TOP_LEVEL_BROWSING_CONTEXT_ID: Cell<Option<TopLevelBrowsingContextId>> = Cell::new(None));
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd, Serialize)]
|
#[derive(
|
||||||
|
Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd, Serialize,
|
||||||
|
)]
|
||||||
pub struct TopLevelBrowsingContextId(BrowsingContextId);
|
pub struct TopLevelBrowsingContextId(BrowsingContextId);
|
||||||
|
|
||||||
impl TopLevelBrowsingContextId {
|
impl TopLevelBrowsingContextId {
|
||||||
|
@ -362,7 +370,9 @@ impl PartialEq<BrowsingContextId> for TopLevelBrowsingContextId {
|
||||||
pub struct HistoryStateIndex(pub NonZeroU32);
|
pub struct HistoryStateIndex(pub NonZeroU32);
|
||||||
malloc_size_of_is_0!(HistoryStateIndex);
|
malloc_size_of_is_0!(HistoryStateIndex);
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd, Serialize)]
|
#[derive(
|
||||||
|
Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd, Serialize,
|
||||||
|
)]
|
||||||
pub struct HistoryStateId {
|
pub struct HistoryStateId {
|
||||||
pub namespace_id: PipelineNamespaceId,
|
pub namespace_id: PipelineNamespaceId,
|
||||||
pub index: HistoryStateIndex,
|
pub index: HistoryStateIndex,
|
||||||
|
@ -390,13 +400,19 @@ impl fmt::Display for HistoryStateId {
|
||||||
// We provide ids just for unit testing.
|
// We provide ids just for unit testing.
|
||||||
pub const TEST_NAMESPACE: PipelineNamespaceId = PipelineNamespaceId(1234);
|
pub const TEST_NAMESPACE: PipelineNamespaceId = PipelineNamespaceId(1234);
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
pub const TEST_PIPELINE_INDEX: PipelineIndex = unsafe { PipelineIndex(NonZeroU32::new_unchecked(5678)) };
|
pub const TEST_PIPELINE_INDEX: PipelineIndex =
|
||||||
pub const TEST_PIPELINE_ID: PipelineId = PipelineId { namespace_id: TEST_NAMESPACE, index: TEST_PIPELINE_INDEX };
|
unsafe { PipelineIndex(NonZeroU32::new_unchecked(5678)) };
|
||||||
|
pub const TEST_PIPELINE_ID: PipelineId = PipelineId {
|
||||||
|
namespace_id: TEST_NAMESPACE,
|
||||||
|
index: TEST_PIPELINE_INDEX,
|
||||||
|
};
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
pub const TEST_BROWSING_CONTEXT_INDEX: BrowsingContextIndex =
|
pub const TEST_BROWSING_CONTEXT_INDEX: BrowsingContextIndex =
|
||||||
unsafe { BrowsingContextIndex(NonZeroU32::new_unchecked(8765)) };
|
unsafe { BrowsingContextIndex(NonZeroU32::new_unchecked(8765)) };
|
||||||
pub const TEST_BROWSING_CONTEXT_ID: BrowsingContextId =
|
pub const TEST_BROWSING_CONTEXT_ID: BrowsingContextId = BrowsingContextId {
|
||||||
BrowsingContextId { namespace_id: TEST_NAMESPACE, index: TEST_BROWSING_CONTEXT_INDEX };
|
namespace_id: TEST_NAMESPACE,
|
||||||
|
index: TEST_BROWSING_CONTEXT_INDEX,
|
||||||
|
};
|
||||||
|
|
||||||
// Used to specify the kind of input method editor appropriate to edit a field.
|
// Used to specify the kind of input method editor appropriate to edit a field.
|
||||||
// This is a subset of htmlinputelement::InputType because some variants of InputType
|
// This is a subset of htmlinputelement::InputType because some variants of InputType
|
||||||
|
|
|
@ -6,9 +6,12 @@
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate bitflags;
|
extern crate bitflags;
|
||||||
#[macro_use] extern crate malloc_size_of;
|
#[macro_use]
|
||||||
#[macro_use] extern crate malloc_size_of_derive;
|
extern crate malloc_size_of;
|
||||||
#[macro_use] extern crate serde;
|
#[macro_use]
|
||||||
|
extern crate malloc_size_of_derive;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate serde;
|
||||||
extern crate webrender_api;
|
extern crate webrender_api;
|
||||||
|
|
||||||
pub mod constellation_msg;
|
pub mod constellation_msg;
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
#![cfg(target_pointer_width = "64")]
|
#![cfg(target_pointer_width = "64")]
|
||||||
|
|
||||||
extern crate msg;
|
extern crate msg;
|
||||||
#[macro_use] extern crate size_of_test;
|
#[macro_use]
|
||||||
|
extern crate size_of_test;
|
||||||
|
|
||||||
use msg::constellation_msg::BrowsingContextId;
|
use msg::constellation_msg::BrowsingContextId;
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
|
@ -14,6 +15,18 @@ use msg::constellation_msg::TopLevelBrowsingContextId;
|
||||||
size_of_test!(test_size_of_pipeline_id, PipelineId, 8);
|
size_of_test!(test_size_of_pipeline_id, PipelineId, 8);
|
||||||
size_of_test!(test_size_of_optional_pipeline_id, Option<PipelineId>, 8);
|
size_of_test!(test_size_of_optional_pipeline_id, Option<PipelineId>, 8);
|
||||||
size_of_test!(test_size_of_browsing_context_id, BrowsingContextId, 8);
|
size_of_test!(test_size_of_browsing_context_id, BrowsingContextId, 8);
|
||||||
size_of_test!(test_size_of_optional_browsing_context_id, Option<BrowsingContextId>, 8);
|
size_of_test!(
|
||||||
size_of_test!(test_size_of_top_level_browsing_context_id, TopLevelBrowsingContextId, 8);
|
test_size_of_optional_browsing_context_id,
|
||||||
size_of_test!(test_size_of_top_level_optional_browsing_context_id, Option<TopLevelBrowsingContextId>, 8);
|
Option<BrowsingContextId>,
|
||||||
|
8
|
||||||
|
);
|
||||||
|
size_of_test!(
|
||||||
|
test_size_of_top_level_browsing_context_id,
|
||||||
|
TopLevelBrowsingContextId,
|
||||||
|
8
|
||||||
|
);
|
||||||
|
size_of_test!(
|
||||||
|
test_size_of_top_level_optional_browsing_context_id,
|
||||||
|
Option<TopLevelBrowsingContextId>,
|
||||||
|
8
|
||||||
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue