mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
layout: Improve and expand category names for layout profiling (#37833)
This improves naming of layout categories and adds tracing for each layout phase. Testing: This just adds / adjusts profiling categories, so doesn't need tests. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
afdd9778e5
commit
19b5e14851
4 changed files with 33 additions and 20 deletions
|
@ -45,6 +45,7 @@ pub struct BoxTree {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BoxTree {
|
impl BoxTree {
|
||||||
|
#[servo_tracing::instrument(name = "Box Tree Construction", skip_all)]
|
||||||
pub(crate) fn construct(context: &LayoutContext, root_element: ServoLayoutNode<'_>) -> Self {
|
pub(crate) fn construct(context: &LayoutContext, root_element: ServoLayoutNode<'_>) -> Self {
|
||||||
let boxes = construct_for_root_element(context, root_element);
|
let boxes = construct_for_root_element(context, root_element);
|
||||||
|
|
||||||
|
@ -191,6 +192,7 @@ fn construct_for_root_element(
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BoxTree {
|
impl BoxTree {
|
||||||
|
#[servo_tracing::instrument(name = "Fragment Tree Construction", skip_all)]
|
||||||
pub(crate) fn layout(
|
pub(crate) fn layout(
|
||||||
&self,
|
&self,
|
||||||
layout_context: &LayoutContext,
|
layout_context: &LayoutContext,
|
||||||
|
|
|
@ -440,7 +440,7 @@ impl Layout for LayoutThread {
|
||||||
|
|
||||||
fn reflow(&mut self, reflow_request: ReflowRequest) -> Option<ReflowResult> {
|
fn reflow(&mut self, reflow_request: ReflowRequest) -> Option<ReflowResult> {
|
||||||
time_profile!(
|
time_profile!(
|
||||||
profile_time::ProfilerCategory::LayoutPerform,
|
profile_time::ProfilerCategory::Layout,
|
||||||
self.profiler_metadata(),
|
self.profiler_metadata(),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|| self.handle_reflow(reflow_request),
|
|| self.handle_reflow(reflow_request),
|
||||||
|
@ -821,27 +821,34 @@ impl LayoutThread {
|
||||||
.restyle
|
.restyle
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.expect("Should not get here if there is not restyle.");
|
.expect("Should not get here if there is not restyle.");
|
||||||
let dirty_root = unsafe {
|
|
||||||
ServoLayoutNode::new(&restyle.dirty_root.unwrap())
|
|
||||||
.as_element()
|
|
||||||
.unwrap()
|
|
||||||
};
|
|
||||||
|
|
||||||
let recalc_style_traversal = RecalcStyle::new(&layout_context);
|
let recalc_style_traversal;
|
||||||
let token = {
|
let dirty_root;
|
||||||
let shared =
|
{
|
||||||
DomTraversal::<ServoLayoutElement>::shared_context(&recalc_style_traversal);
|
#[cfg(feature = "tracing")]
|
||||||
RecalcStyle::pre_traverse(dirty_root, shared)
|
let _span = tracing::trace_span!("Styling", servo_profiling = true).entered();
|
||||||
};
|
|
||||||
|
|
||||||
if !token.should_traverse() {
|
let original_dirty_root = unsafe {
|
||||||
layout_context.style_context.stylist.rule_tree().maybe_gc();
|
ServoLayoutNode::new(&restyle.dirty_root.unwrap())
|
||||||
return (RestyleDamage::empty(), IFrameSizes::default());
|
.as_element()
|
||||||
|
.unwrap()
|
||||||
|
};
|
||||||
|
|
||||||
|
recalc_style_traversal = RecalcStyle::new(&layout_context);
|
||||||
|
let token = {
|
||||||
|
let shared =
|
||||||
|
DomTraversal::<ServoLayoutElement>::shared_context(&recalc_style_traversal);
|
||||||
|
RecalcStyle::pre_traverse(original_dirty_root, shared)
|
||||||
|
};
|
||||||
|
|
||||||
|
if !token.should_traverse() {
|
||||||
|
layout_context.style_context.stylist.rule_tree().maybe_gc();
|
||||||
|
return (RestyleDamage::empty(), IFrameSizes::default());
|
||||||
|
}
|
||||||
|
|
||||||
|
dirty_root = driver::traverse_dom(&recalc_style_traversal, token, rayon_pool).as_node();
|
||||||
}
|
}
|
||||||
|
|
||||||
let dirty_root: ServoLayoutNode =
|
|
||||||
driver::traverse_dom(&recalc_style_traversal, token, rayon_pool).as_node();
|
|
||||||
|
|
||||||
let root_node = root_element.as_node();
|
let root_node = root_element.as_node();
|
||||||
let mut damage = compute_damage_and_repair_style(&layout_context.style_context, root_node);
|
let mut damage = compute_damage_and_repair_style(&layout_context.style_context, root_node);
|
||||||
if viewport_changed {
|
if viewport_changed {
|
||||||
|
@ -909,6 +916,7 @@ impl LayoutThread {
|
||||||
(damage, std::mem::take(&mut *iframe_sizes))
|
(damage, std::mem::take(&mut *iframe_sizes))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[servo_tracing::instrument(name = "Overflow Calculation", skip_all)]
|
||||||
fn calculate_overflow(&self, damage: RestyleDamage) {
|
fn calculate_overflow(&self, damage: RestyleDamage) {
|
||||||
if !damage.contains(RestyleDamage::RECALCULATE_OVERFLOW) {
|
if !damage.contains(RestyleDamage::RECALCULATE_OVERFLOW) {
|
||||||
return;
|
return;
|
||||||
|
@ -927,6 +935,7 @@ impl LayoutThread {
|
||||||
self.need_new_stacking_context_tree.set(true);
|
self.need_new_stacking_context_tree.set(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[servo_tracing::instrument(name = "Stacking Context Tree Construction", skip_all)]
|
||||||
fn build_stacking_context_tree(&self, reflow_request: &ReflowRequest, damage: RestyleDamage) {
|
fn build_stacking_context_tree(&self, reflow_request: &ReflowRequest, damage: RestyleDamage) {
|
||||||
if !ReflowPhases::necessary(&reflow_request.reflow_goal)
|
if !ReflowPhases::necessary(&reflow_request.reflow_goal)
|
||||||
.contains(ReflowPhases::StackingContextTreeConstruction)
|
.contains(ReflowPhases::StackingContextTreeConstruction)
|
||||||
|
@ -999,6 +1008,7 @@ impl LayoutThread {
|
||||||
|
|
||||||
/// Build the display list for the current layout and send it to the renderer. If no display
|
/// Build the display list for the current layout and send it to the renderer. If no display
|
||||||
/// list is built, returns false.
|
/// list is built, returns false.
|
||||||
|
#[servo_tracing::instrument(name = "Display List Construction", skip_all)]
|
||||||
fn build_display_list(
|
fn build_display_list(
|
||||||
&self,
|
&self,
|
||||||
reflow_request: &ReflowRequest,
|
reflow_request: &ReflowRequest,
|
||||||
|
|
|
@ -92,6 +92,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[servo_tracing::instrument(skip_all)]
|
||||||
pub(crate) fn compute_damage_and_repair_style(
|
pub(crate) fn compute_damage_and_repair_style(
|
||||||
context: &SharedStyleContext,
|
context: &SharedStyleContext,
|
||||||
node: ServoLayoutNode<'_>,
|
node: ServoLayoutNode<'_>,
|
||||||
|
|
|
@ -66,7 +66,7 @@ pub enum ProfilerCategory {
|
||||||
Compositing = 0x00,
|
Compositing = 0x00,
|
||||||
|
|
||||||
/// The script thread is doing layout work.
|
/// The script thread is doing layout work.
|
||||||
LayoutPerform = 0x10,
|
Layout = 0x10,
|
||||||
|
|
||||||
ImageSaving = 0x51,
|
ImageSaving = 0x51,
|
||||||
ScriptAttachLayout = 0x60,
|
ScriptAttachLayout = 0x60,
|
||||||
|
@ -126,7 +126,7 @@ impl ProfilerCategory {
|
||||||
pub const fn variant_name(&self) -> &'static str {
|
pub const fn variant_name(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
ProfilerCategory::Compositing => "Compositing",
|
ProfilerCategory::Compositing => "Compositing",
|
||||||
ProfilerCategory::LayoutPerform => "LayoutPerform",
|
ProfilerCategory::Layout => "Layout",
|
||||||
ProfilerCategory::ImageSaving => "ImageSaving",
|
ProfilerCategory::ImageSaving => "ImageSaving",
|
||||||
ProfilerCategory::ScriptAttachLayout => "ScriptAttachLayout",
|
ProfilerCategory::ScriptAttachLayout => "ScriptAttachLayout",
|
||||||
ProfilerCategory::ScriptConstellationMsg => "ScriptConstellationMsg",
|
ProfilerCategory::ScriptConstellationMsg => "ScriptConstellationMsg",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue