mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Various memory measurement improvements (#36834)
The two significant changes here are 1) a commit that frees memory used to perform memory reporting once the reporting is complete, 2) memory reporting for the system font service. There are various other commits that remove `#[ignore_malloc_size_of]` attributes for data that we are now able to measure, but they do not significantly change our measurements when testing servo.org. Testing: Comparing the output of about:memory on servo.org. --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
e9f364ef51
commit
ba8f923201
19 changed files with 135 additions and 49 deletions
|
@ -10,6 +10,7 @@ pub(crate) use std::cell::{Ref, RefCell, RefMut};
|
|||
|
||||
#[cfg(feature = "refcell_backtrace")]
|
||||
pub(crate) use accountable_refcell::{Ref, RefCell, RefMut, ref_filter_map};
|
||||
use malloc_size_of::{MallocConditionalSizeOf, MallocSizeOfOps};
|
||||
#[cfg(not(feature = "refcell_backtrace"))]
|
||||
pub(crate) use ref_filter_map::ref_filter_map;
|
||||
|
||||
|
@ -24,6 +25,12 @@ pub(crate) struct DomRefCell<T> {
|
|||
value: RefCell<T>,
|
||||
}
|
||||
|
||||
impl<T: MallocConditionalSizeOf> MallocConditionalSizeOf for DomRefCell<T> {
|
||||
fn conditional_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
||||
self.value.borrow().conditional_size_of(ops)
|
||||
}
|
||||
}
|
||||
|
||||
// Functionality specific to Servo's `DomRefCell` type
|
||||
// ===================================================
|
||||
|
||||
|
|
|
@ -179,7 +179,7 @@ pub struct Element {
|
|||
/// <https://dom.spec.whatwg.org/#concept-element-is-value>
|
||||
#[no_trace]
|
||||
is: DomRefCell<Option<LocalName>>,
|
||||
#[ignore_malloc_size_of = "Arc"]
|
||||
#[conditional_malloc_size_of]
|
||||
#[no_trace]
|
||||
style_attribute: DomRefCell<Option<Arc<Locked<PropertyDeclarationBlock>>>>,
|
||||
attr_list: MutNullableDom<NamedNodeMap>,
|
||||
|
|
|
@ -97,6 +97,7 @@ enum ParseState {
|
|||
AfterDescriptor,
|
||||
}
|
||||
|
||||
#[derive(MallocSizeOf)]
|
||||
pub(crate) struct SourceSet {
|
||||
image_sources: Vec<ImageSource>,
|
||||
source_size: SourceSizeList,
|
||||
|
@ -111,13 +112,13 @@ impl SourceSet {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq)]
|
||||
pub struct ImageSource {
|
||||
pub url: String,
|
||||
pub descriptor: Descriptor,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq)]
|
||||
pub struct Descriptor {
|
||||
pub width: Option<u32>,
|
||||
pub density: Option<f64>,
|
||||
|
@ -145,7 +146,7 @@ struct ImageRequest {
|
|||
parsed_url: Option<ServoUrl>,
|
||||
source_url: Option<USVString>,
|
||||
blocker: DomRefCell<Option<LoadBlocker>>,
|
||||
#[ignore_malloc_size_of = "Arc"]
|
||||
#[conditional_malloc_size_of]
|
||||
#[no_trace]
|
||||
image: Option<Arc<Image>>,
|
||||
#[no_trace]
|
||||
|
@ -162,7 +163,6 @@ pub(crate) struct HTMLImageElement {
|
|||
pending_request: DomRefCell<ImageRequest>,
|
||||
form_owner: MutNullableDom<HTMLFormElement>,
|
||||
generation: Cell<u32>,
|
||||
#[ignore_malloc_size_of = "SourceSet"]
|
||||
source_set: DomRefCell<SourceSet>,
|
||||
last_selected_source: DomRefCell<Option<USVString>>,
|
||||
#[ignore_malloc_size_of = "promises are hard"]
|
||||
|
|
|
@ -98,7 +98,7 @@ pub(crate) struct HTMLLinkElement {
|
|||
#[no_trace]
|
||||
relations: Cell<LinkRelations>,
|
||||
|
||||
#[ignore_malloc_size_of = "Arc"]
|
||||
#[conditional_malloc_size_of]
|
||||
#[no_trace]
|
||||
stylesheet: DomRefCell<Option<Arc<Stylesheet>>>,
|
||||
cssom_stylesheet: MutNullableDom<CSSStyleSheet>,
|
||||
|
|
|
@ -281,19 +281,18 @@ pub(crate) enum ScriptType {
|
|||
pub(crate) struct CompiledSourceCode {
|
||||
#[ignore_malloc_size_of = "SM handles JS values"]
|
||||
pub(crate) source_code: Stencil,
|
||||
#[ignore_malloc_size_of = "Rc is hard"]
|
||||
#[conditional_malloc_size_of = "Rc is hard"]
|
||||
pub(crate) original_text: Rc<DOMString>,
|
||||
}
|
||||
|
||||
#[derive(JSTraceable)]
|
||||
#[derive(JSTraceable, MallocSizeOf)]
|
||||
pub(crate) enum SourceCode {
|
||||
Text(Rc<DOMString>),
|
||||
Text(#[conditional_malloc_size_of] Rc<DOMString>),
|
||||
Compiled(CompiledSourceCode),
|
||||
}
|
||||
|
||||
#[derive(JSTraceable, MallocSizeOf)]
|
||||
pub(crate) struct ScriptOrigin {
|
||||
#[ignore_malloc_size_of = "Rc is hard"]
|
||||
code: SourceCode,
|
||||
#[no_trace]
|
||||
url: ServoUrl,
|
||||
|
|
|
@ -34,7 +34,7 @@ use crate::stylesheet_loader::{StylesheetLoader, StylesheetOwner};
|
|||
#[dom_struct]
|
||||
pub(crate) struct HTMLStyleElement {
|
||||
htmlelement: HTMLElement,
|
||||
#[ignore_malloc_size_of = "Arc"]
|
||||
#[conditional_malloc_size_of]
|
||||
#[no_trace]
|
||||
stylesheet: DomRefCell<Option<Arc<Stylesheet>>>,
|
||||
cssom_stylesheet: MutNullableDom<CSSStyleSheet>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue