diff options
author | Josh Matthews <josh@joshmatthews.net> | 2025-04-18 16:05:15 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-18 20:05:15 +0000 |
commit | c787688afc873e78d9526809cf7d2cde689c0ae4 (patch) | |
tree | bf852fcac1370e251e5282c331227c13c7fbd3dd /components/malloc_size_of/lib.rs | |
parent | add8c51f4728fbafe56781670f9ae4b1a754e094 (diff) | |
download | servo-c787688afc873e78d9526809cf7d2cde689c0ae4.tar.gz servo-c787688afc873e78d9526809cf7d2cde689c0ae4.zip |
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>
Diffstat (limited to 'components/malloc_size_of/lib.rs')
-rw-r--r-- | components/malloc_size_of/lib.rs | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/components/malloc_size_of/lib.rs b/components/malloc_size_of/lib.rs index dbecc0da2c3..b7f677f8044 100644 --- a/components/malloc_size_of/lib.rs +++ b/components/malloc_size_of/lib.rs @@ -52,6 +52,7 @@ use std::hash::{BuildHasher, Hash}; use std::ops::Range; use std::sync::Arc; +use style::values::generics::length::GenericLengthPercentageOrAuto; pub use stylo_malloc_size_of::MallocSizeOfOps; use uuid::Uuid; @@ -219,6 +220,26 @@ where } } +impl<T: MallocConditionalSizeOf> MallocConditionalSizeOf for Option<T> { + fn conditional_size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + if let Some(val) = self.as_ref() { + val.conditional_size_of(ops) + } else { + 0 + } + } +} + +impl<T: MallocConditionalSizeOf> MallocConditionalSizeOf for Vec<T> { + fn conditional_size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + let mut n = self.shallow_size_of(ops); + for elem in self.iter() { + n += elem.conditional_size_of(ops); + } + n + } +} + impl<T: MallocSizeOf> MallocSizeOf for Option<T> { fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { if let Some(val) = self.as_ref() { @@ -726,7 +747,11 @@ malloc_size_of_is_0!(std::time::Duration); malloc_size_of_is_0!(std::time::Instant); malloc_size_of_is_0!(std::time::SystemTime); malloc_size_of_is_0!(style::font_face::SourceList); +malloc_size_of_is_0!(style::properties::ComputedValues); malloc_size_of_is_0!(style::queries::values::PrefersColorScheme); +malloc_size_of_is_0!(taffy::Layout); +malloc_size_of_is_0!(unicode_bidi::Level); +malloc_size_of_is_0!(unicode_script::Script); macro_rules! malloc_size_of_is_webrender_malloc_size_of( ($($ty:ty),+) => ( @@ -790,6 +815,12 @@ where } } +impl<T: MallocSizeOf> MallocSizeOf for atomic_refcell::AtomicRefCell<T> { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.borrow().size_of(ops) + } +} + malloc_size_of_is_stylo_malloc_size_of!(style::animation::DocumentAnimationSet); malloc_size_of_is_stylo_malloc_size_of!(style::attr::AttrIdentifier); malloc_size_of_is_stylo_malloc_size_of!(style::attr::AttrValue); @@ -797,7 +828,15 @@ malloc_size_of_is_stylo_malloc_size_of!(style::color::AbsoluteColor); malloc_size_of_is_stylo_malloc_size_of!(style::computed_values::font_variant_caps::T); malloc_size_of_is_stylo_malloc_size_of!(style::dom::OpaqueNode); malloc_size_of_is_stylo_malloc_size_of!(style::invalidation::element::restyle_hints::RestyleHint); +malloc_size_of_is_stylo_malloc_size_of!(style::logical_geometry::WritingMode); malloc_size_of_is_stylo_malloc_size_of!(style::media_queries::MediaList); +malloc_size_of_is_stylo_malloc_size_of!( + style::properties::longhands::align_items::computed_value::T +); +malloc_size_of_is_stylo_malloc_size_of!( + style::properties::longhands::flex_direction::computed_value::T +); +malloc_size_of_is_stylo_malloc_size_of!(style::properties::longhands::flex_wrap::computed_value::T); malloc_size_of_is_stylo_malloc_size_of!(style::properties::style_structs::Font); malloc_size_of_is_stylo_malloc_size_of!(style::selector_parser::PseudoElement); malloc_size_of_is_stylo_malloc_size_of!(style::selector_parser::RestyleDamage); @@ -805,8 +844,22 @@ malloc_size_of_is_stylo_malloc_size_of!(style::selector_parser::Snapshot); malloc_size_of_is_stylo_malloc_size_of!(style::shared_lock::SharedRwLock); malloc_size_of_is_stylo_malloc_size_of!(style::stylesheets::DocumentStyleSheet); malloc_size_of_is_stylo_malloc_size_of!(style::stylist::Stylist); +malloc_size_of_is_stylo_malloc_size_of!(style::values::computed::AlignContent); +malloc_size_of_is_stylo_malloc_size_of!(style::values::computed::BorderStyle); malloc_size_of_is_stylo_malloc_size_of!(style::values::computed::FontStretch); malloc_size_of_is_stylo_malloc_size_of!(style::values::computed::FontStyle); malloc_size_of_is_stylo_malloc_size_of!(style::values::computed::FontWeight); malloc_size_of_is_stylo_malloc_size_of!(style::values::computed::font::SingleFontFamily); +malloc_size_of_is_stylo_malloc_size_of!(style::values::computed::JustifyContent); +malloc_size_of_is_stylo_malloc_size_of!(style::values::specified::align::AlignFlags); +malloc_size_of_is_stylo_malloc_size_of!(style::values::specified::TextDecorationLine); malloc_size_of_is_stylo_malloc_size_of!(stylo_dom::ElementState); + +impl<T> MallocSizeOf for GenericLengthPercentageOrAuto<T> +where + T: stylo_malloc_size_of::MallocSizeOf, +{ + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + <GenericLengthPercentageOrAuto<T> as stylo_malloc_size_of::MallocSizeOf>::size_of(self, ops) + } +} |