diff options
author | Josh Matthews <josh@joshmatthews.net> | 2025-05-07 00:00:12 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-07 04:00:12 +0000 |
commit | ba8f9232017266d24f170f371d56a5bc8259bf59 (patch) | |
tree | e1711077285c38a2a40b0fe220c94846072ef5ee /components/shared | |
parent | e9f364ef51b067192c67c9aaab936151fa577ed5 (diff) | |
download | servo-ba8f9232017266d24f170f371d56a5bc8259bf59.tar.gz servo-ba8f9232017266d24f170f371d56a5bc8259bf59.zip |
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>
Diffstat (limited to 'components/shared')
-rw-r--r-- | components/shared/compositing/lib.rs | 3 | ||||
-rw-r--r-- | components/shared/profile/mem.rs | 6 |
2 files changed, 7 insertions, 2 deletions
diff --git a/components/shared/compositing/lib.rs b/components/shared/compositing/lib.rs index 31371f87529..2bc2cc74d50 100644 --- a/components/shared/compositing/lib.rs +++ b/components/shared/compositing/lib.rs @@ -14,6 +14,7 @@ use embedder_traits::{ use euclid::Rect; use ipc_channel::ipc::IpcSender; use log::warn; +use malloc_size_of_derive::MallocSizeOf; use pixels::Image; use strum_macros::IntoStaticStr; use style_traits::CSSPixel; @@ -188,7 +189,7 @@ pub struct CompositionPipeline { } /// A mechanism to send messages from ScriptThread to the parent process' WebRender instance. -#[derive(Clone, Deserialize, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct CrossProcessCompositorApi(pub IpcSender<CompositorMsg>); impl CrossProcessCompositorApi { diff --git a/components/shared/profile/mem.rs b/components/shared/profile/mem.rs index 1be4eb5abc4..b626facd042 100644 --- a/components/shared/profile/mem.rs +++ b/components/shared/profile/mem.rs @@ -279,7 +279,6 @@ thread_local!(static SEEN_POINTERS: LazyCell<RefCell<HashSet<*const c_void>>> = /// The function is expected to call all the desired [MallocSizeOf::size_of] /// for allocations reachable from the current thread. pub fn perform_memory_report<F: FnOnce(&mut MallocSizeOfOps)>(f: F) { - SEEN_POINTERS.with(|pointers| pointers.borrow_mut().clear()); let seen_pointer = move |ptr| SEEN_POINTERS.with(|pointers| !pointers.borrow_mut().insert(ptr)); let mut ops = MallocSizeOfOps::new( servo_allocator::usable_size, @@ -287,4 +286,9 @@ pub fn perform_memory_report<F: FnOnce(&mut MallocSizeOfOps)>(f: F) { Some(Box::new(seen_pointer)), ); f(&mut ops); + SEEN_POINTERS.with(|pointers| { + let mut pointers = pointers.borrow_mut(); + pointers.clear(); + pointers.shrink_to_fit(); + }); } |