fonts: Measure more FontContext heap usage. (#38733)

Replace a hand-written MallocSizeOf implementation with an automatically
derived one. This exposes more than 1MB of previously-untracked heap
data on servo.org.

Testing: Compared about:memory output for servo.org before and after.
Part of: #11559

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2025-08-17 14:59:30 -04:00 committed by GitHub
parent d490c5c06b
commit 9da8142e2a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 59 additions and 32 deletions

View file

@ -4,6 +4,7 @@
use std::borrow::ToOwned;
use std::collections::HashMap;
use std::ops::Deref;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, OnceLock};
use std::time::Instant;
@ -548,7 +549,15 @@ impl Font {
}
}
pub type FontRef = Arc<Font>;
#[derive(Clone, MallocSizeOf)]
pub struct FontRef(#[conditional_malloc_size_of] pub(crate) Arc<Font>);
impl Deref for FontRef {
type Target = Arc<Font>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
/// A `FontGroup` is a prioritised list of fonts for a given set of font styles. It is used by
/// `TextRun` to decide which font to render a character with. If none of the fonts listed in the