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

@ -3,6 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use std::collections::HashMap;
use std::ops::Deref;
use std::sync::Arc;
use log::warn;
@ -21,7 +22,16 @@ pub struct FontStore {
web_fonts_loading_for_stylesheets: Vec<(DocumentStyleSheet, usize)>,
web_fonts_loading_for_script: usize,
}
pub(crate) type CrossThreadFontStore = Arc<RwLock<FontStore>>;
#[derive(Default, MallocSizeOf)]
pub(crate) struct CrossThreadFontStore(#[conditional_malloc_size_of] Arc<RwLock<FontStore>>);
impl Deref for CrossThreadFontStore {
type Target = Arc<RwLock<FontStore>>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl FontStore {
pub(crate) fn clear(&mut self) {