layout: Report memory usage for fragment and box trees. (#36553)

Add memory reporter integration for the fragment and box trees that are
persisted in the layout thread.

Testing: Looked at the numbers for https://servo.org and
https://html.spec.whatwg.org/. The former was very small, but the latter
was 700mb.

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2025-04-18 16:05:15 -04:00 committed by GitHub
parent add8c51f47
commit c787688afc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 230 additions and 69 deletions

View file

@ -12,6 +12,7 @@ use fonts::{
};
use fonts_traits::ByteIndex;
use log::warn;
use malloc_size_of_derive::MallocSizeOf;
use range::Range as ServoRange;
use servo_arc::Arc;
use style::computed_values::text_rendering::T as TextRendering;
@ -37,9 +38,10 @@ pub(crate) const XI_LINE_BREAKING_CLASS_WJ: u8 = 30;
pub(crate) const XI_LINE_BREAKING_CLASS_ZWJ: u8 = 42;
/// <https://www.w3.org/TR/css-display-3/#css-text-run>
#[derive(Debug)]
#[derive(Debug, MallocSizeOf)]
pub(crate) struct TextRun {
pub base_fragment_info: BaseFragmentInfo,
#[conditional_malloc_size_of]
pub parent_style: Arc<ComputedValues>,
pub text_range: Range<usize>,
@ -47,6 +49,7 @@ pub(crate) struct TextRun {
/// segments, and shaped.
pub shaped_text: Vec<TextRunSegment>,
pub selection_range: Option<ServoRange<ByteIndex>>,
#[conditional_malloc_size_of]
pub selected_style: Arc<ComputedValues>,
}
@ -64,7 +67,7 @@ enum SegmentStartSoftWrapPolicy {
FollowLinebreaker,
}
#[derive(Debug)]
#[derive(Debug, MallocSizeOf)]
pub(crate) struct TextRunSegment {
/// The index of this font in the parent [`super::InlineFormattingContext`]'s collection of font
/// information.