mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +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 {
|
||||
#[servo_tracing::instrument(name = "Box Tree Construction", skip_all)]
|
||||
pub(crate) fn construct(context: &LayoutContext, root_element: ServoLayoutNode<'_>) -> Self {
|
||||
let boxes = construct_for_root_element(context, root_element);
|
||||
|
||||
|
@ -191,6 +192,7 @@ fn construct_for_root_element(
|
|||
}
|
||||
|
||||
impl BoxTree {
|
||||
#[servo_tracing::instrument(name = "Fragment Tree Construction", skip_all)]
|
||||
pub(crate) fn layout(
|
||||
&self,
|
||||
layout_context: &LayoutContext,
|
||||
|
|
|
@ -440,7 +440,7 @@ impl Layout for LayoutThread {
|
|||
|
||||
fn reflow(&mut self, reflow_request: ReflowRequest) -> Option<ReflowResult> {
|
||||
time_profile!(
|
||||
profile_time::ProfilerCategory::LayoutPerform,
|
||||
profile_time::ProfilerCategory::Layout,
|
||||
self.profiler_metadata(),
|
||||
self.time_profiler_chan.clone(),
|
||||
|| self.handle_reflow(reflow_request),
|
||||
|
@ -821,27 +821,34 @@ impl LayoutThread {
|
|||
.restyle
|
||||
.as_ref()
|
||||
.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 token = {
|
||||
let shared =
|
||||
DomTraversal::<ServoLayoutElement>::shared_context(&recalc_style_traversal);
|
||||
RecalcStyle::pre_traverse(dirty_root, shared)
|
||||
};
|
||||
let recalc_style_traversal;
|
||||
let dirty_root;
|
||||
{
|
||||
#[cfg(feature = "tracing")]
|
||||
let _span = tracing::trace_span!("Styling", servo_profiling = true).entered();
|
||||
|
||||
if !token.should_traverse() {
|
||||
layout_context.style_context.stylist.rule_tree().maybe_gc();
|
||||
return (RestyleDamage::empty(), IFrameSizes::default());
|
||||
let original_dirty_root = unsafe {
|
||||
ServoLayoutNode::new(&restyle.dirty_root.unwrap())
|
||||
.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 mut damage = compute_damage_and_repair_style(&layout_context.style_context, root_node);
|
||||
if viewport_changed {
|
||||
|
@ -909,6 +916,7 @@ impl LayoutThread {
|
|||
(damage, std::mem::take(&mut *iframe_sizes))
|
||||
}
|
||||
|
||||
#[servo_tracing::instrument(name = "Overflow Calculation", skip_all)]
|
||||
fn calculate_overflow(&self, damage: RestyleDamage) {
|
||||
if !damage.contains(RestyleDamage::RECALCULATE_OVERFLOW) {
|
||||
return;
|
||||
|
@ -927,6 +935,7 @@ impl LayoutThread {
|
|||
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) {
|
||||
if !ReflowPhases::necessary(&reflow_request.reflow_goal)
|
||||
.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
|
||||
/// list is built, returns false.
|
||||
#[servo_tracing::instrument(name = "Display List Construction", skip_all)]
|
||||
fn build_display_list(
|
||||
&self,
|
||||
reflow_request: &ReflowRequest,
|
||||
|
|
|
@ -92,6 +92,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
#[servo_tracing::instrument(skip_all)]
|
||||
pub(crate) fn compute_damage_and_repair_style(
|
||||
context: &SharedStyleContext,
|
||||
node: ServoLayoutNode<'_>,
|
||||
|
|
|
@ -66,7 +66,7 @@ pub enum ProfilerCategory {
|
|||
Compositing = 0x00,
|
||||
|
||||
/// The script thread is doing layout work.
|
||||
LayoutPerform = 0x10,
|
||||
Layout = 0x10,
|
||||
|
||||
ImageSaving = 0x51,
|
||||
ScriptAttachLayout = 0x60,
|
||||
|
@ -126,7 +126,7 @@ impl ProfilerCategory {
|
|||
pub const fn variant_name(&self) -> &'static str {
|
||||
match self {
|
||||
ProfilerCategory::Compositing => "Compositing",
|
||||
ProfilerCategory::LayoutPerform => "LayoutPerform",
|
||||
ProfilerCategory::Layout => "Layout",
|
||||
ProfilerCategory::ImageSaving => "ImageSaving",
|
||||
ProfilerCategory::ScriptAttachLayout => "ScriptAttachLayout",
|
||||
ProfilerCategory::ScriptConstellationMsg => "ScriptConstellationMsg",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue