mirror of
https://github.com/servo/servo.git
synced 2025-09-27 23:30:08 +01:00
layout: Measure stacking context tree in layout thread memory report (#38762)
Measures the memory usage of the stacking context tree in the memory report of the layout thread by adding `MallocSizeOf` to `StackingContextTree` and all the types required for that. Also requires adding `MallocSizeOf` to some webrender types. Testing: Manually looked at about:memory <img width="636" height="241" alt="image" src="https://github.com/user-attachments/assets/6bf9d65a-0bf0-4a99-99b5-ddedba3269c1" /> Fixes: https://github.com/servo/servo/issues/38725 --------- Signed-off-by: Rahul Menon <menonrahul02@gmail.com>
This commit is contained in:
parent
634c1897cf
commit
9cd019403f
7 changed files with 53 additions and 23 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
use app_units::Au;
|
||||
use base::id::ScrollTreeNodeId;
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use style::values::computed::basic_shape::{BasicShape, ClipPath};
|
||||
use style::values::computed::length_percentage::NonNegativeLengthPercentage;
|
||||
use style::values::computed::position::Position;
|
||||
|
@ -16,7 +17,7 @@ use super::{BuilderForBoxFragment, compute_margin_box_radius, normalize_radii};
|
|||
|
||||
/// An identifier for a clip used during StackingContextTree construction. This is a simple index in
|
||||
/// a [`ClipStore`]s vector of clips.
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq)]
|
||||
pub(crate) struct ClipId(pub usize);
|
||||
|
||||
impl ClipId {
|
||||
|
@ -27,7 +28,7 @@ impl ClipId {
|
|||
/// All the information needed to create a clip on a WebRender display list. These are created at
|
||||
/// two times: during `StackingContextTree` creation and during WebRender display list construction.
|
||||
/// Only the former are stored in a [`ClipStore`].
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, MallocSizeOf)]
|
||||
pub(crate) struct Clip {
|
||||
pub id: ClipId,
|
||||
pub radii: BorderRadius,
|
||||
|
@ -39,7 +40,7 @@ pub(crate) struct Clip {
|
|||
/// A simple vector of [`Clip`] that is built during `StackingContextTree` construction.
|
||||
/// These are later turned into WebRender clips and clip chains during WebRender display
|
||||
/// list construction.
|
||||
#[derive(Clone, Default)]
|
||||
#[derive(Clone, Default, MallocSizeOf)]
|
||||
pub(crate) struct StackingContextTreeClipStore(pub Vec<Clip>);
|
||||
|
||||
impl StackingContextTreeClipStore {
|
||||
|
|
|
@ -18,6 +18,7 @@ use embedder_traits::ViewportDetails;
|
|||
use euclid::SideOffsets2D;
|
||||
use euclid::default::{Point2D, Rect, Size2D};
|
||||
use log::warn;
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use servo_config::opts::DebugOptions;
|
||||
use style::Zero;
|
||||
use style::color::AbsoluteColor;
|
||||
|
@ -92,7 +93,7 @@ impl ContainingBlock {
|
|||
|
||||
pub(crate) type ContainingBlockInfo<'a> = ContainingBlockManager<'a, ContainingBlock>;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
|
||||
#[derive(Clone, Copy, Debug, Eq, Ord, MallocSizeOf, PartialEq, PartialOrd)]
|
||||
pub(crate) enum StackingContextSection {
|
||||
OwnBackgroundsAndBorders,
|
||||
DescendantBackgroundsAndBorders,
|
||||
|
@ -100,6 +101,7 @@ pub(crate) enum StackingContextSection {
|
|||
Outline,
|
||||
}
|
||||
|
||||
#[derive(MallocSizeOf)]
|
||||
pub(crate) struct ScrollFrameHitTestItem {
|
||||
/// The [`ScrollTreeNodeId`] of the spatial node that contains this hit test item.
|
||||
pub scroll_node_id: ScrollTreeNodeId,
|
||||
|
@ -116,6 +118,7 @@ pub(crate) struct ScrollFrameHitTestItem {
|
|||
pub external_scroll_id: ExternalScrollId,
|
||||
}
|
||||
|
||||
#[derive(MallocSizeOf)]
|
||||
pub(crate) struct StackingContextTree {
|
||||
/// The root stacking context of this [`StackingContextTree`].
|
||||
pub root_stacking_context: StackingContext,
|
||||
|
@ -282,7 +285,7 @@ impl StackingContextTree {
|
|||
}
|
||||
|
||||
/// The text decorations for a Fragment, collecting during [`StackingContextTree`] construction.
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, MallocSizeOf)]
|
||||
pub(crate) struct FragmentTextDecoration {
|
||||
pub line: TextDecorationLine,
|
||||
pub color: AbsoluteColor,
|
||||
|
@ -293,6 +296,7 @@ pub(crate) struct FragmentTextDecoration {
|
|||
///
|
||||
/// This is generally part of a fragment, like its borders or foreground, but it
|
||||
/// can also be a stacking container that needs to be painted in fragment order.
|
||||
#[derive(MallocSizeOf)]
|
||||
pub(crate) enum StackingContextContent {
|
||||
/// A fragment that does not generate a stacking context or stacking container.
|
||||
Fragment {
|
||||
|
@ -303,6 +307,7 @@ pub(crate) enum StackingContextContent {
|
|||
containing_block: PhysicalRect<Au>,
|
||||
fragment: Fragment,
|
||||
is_collapsed_table_borders: bool,
|
||||
#[conditional_malloc_size_of]
|
||||
text_decorations: Arc<Vec<FragmentTextDecoration>>,
|
||||
},
|
||||
|
||||
|
@ -354,7 +359,7 @@ impl StackingContextContent {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq)]
|
||||
pub(crate) enum StackingContextType {
|
||||
RealStackingContext,
|
||||
PositionedStackingContainer,
|
||||
|
@ -367,6 +372,7 @@ pub(crate) enum StackingContextType {
|
|||
///
|
||||
/// We use the term “real stacking context” in situations that call for a
|
||||
/// stacking context but not a stacking container.
|
||||
#[derive(MallocSizeOf)]
|
||||
pub struct StackingContext {
|
||||
/// The spatial id of this fragment. This is used to properly handle
|
||||
/// things like preserve-3d.
|
||||
|
@ -416,14 +422,14 @@ pub struct StackingContext {
|
|||
}
|
||||
|
||||
/// Refers to one of the child contents or stacking contexts of a [StackingContext].
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Clone, Copy, MallocSizeOf)]
|
||||
pub struct DebugPrintItem {
|
||||
field: DebugPrintField,
|
||||
index: usize,
|
||||
}
|
||||
|
||||
/// Refers to one of the vecs of a [StackingContext].
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Clone, Copy, MallocSizeOf)]
|
||||
pub enum DebugPrintField {
|
||||
Contents,
|
||||
RealStackingContextsAndPositionedStackingContainers,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue