mirror of
https://github.com/servo/servo.git
synced 2025-09-30 00:29:14 +01:00
script: Measure heap usage of various ignored fields (#38791)
These changes allow using MallocSizeOf/`#[conditional_malloc_size_of]` on WebIDL callback values, and then fix a grab bag of places in the script crate that previously ignored those values. There are also some commits removing ignored fields that involved Arc/Rc that are not WebIDL callbacks, since they are now easier to support with the `#[conditional_malloc_size_of]` attribute. Testing: Manual testing on about:memory for servo.org. --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
604b6ea26d
commit
636e7211e0
16 changed files with 44 additions and 38 deletions
|
@ -823,7 +823,7 @@ pub(crate) fn create_array_buffer_with_size(
|
|||
#[cfg(feature = "webgpu")]
|
||||
#[derive(JSTraceable, MallocSizeOf)]
|
||||
pub(crate) struct DataBlock {
|
||||
#[ignore_malloc_size_of = "Arc"]
|
||||
#[conditional_malloc_size_of]
|
||||
data: Arc<Box<[u8]>>,
|
||||
/// Data views (mutable subslices of data)
|
||||
data_views: Vec<DataView>,
|
||||
|
|
|
@ -614,28 +614,28 @@ impl CustomElementRegistryMethods<crate::DomTypeHolder> for CustomElementRegistr
|
|||
|
||||
#[derive(Clone, JSTraceable, MallocSizeOf)]
|
||||
pub(crate) struct LifecycleCallbacks {
|
||||
#[ignore_malloc_size_of = "Rc"]
|
||||
#[conditional_malloc_size_of]
|
||||
connected_callback: Option<Rc<Function>>,
|
||||
|
||||
#[ignore_malloc_size_of = "Rc"]
|
||||
#[conditional_malloc_size_of]
|
||||
disconnected_callback: Option<Rc<Function>>,
|
||||
|
||||
#[ignore_malloc_size_of = "Rc"]
|
||||
#[conditional_malloc_size_of]
|
||||
adopted_callback: Option<Rc<Function>>,
|
||||
|
||||
#[ignore_malloc_size_of = "Rc"]
|
||||
#[conditional_malloc_size_of]
|
||||
attribute_changed_callback: Option<Rc<Function>>,
|
||||
|
||||
#[ignore_malloc_size_of = "Rc"]
|
||||
#[conditional_malloc_size_of]
|
||||
form_associated_callback: Option<Rc<Function>>,
|
||||
|
||||
#[ignore_malloc_size_of = "Rc"]
|
||||
#[conditional_malloc_size_of]
|
||||
form_reset_callback: Option<Rc<Function>>,
|
||||
|
||||
#[ignore_malloc_size_of = "Rc"]
|
||||
#[conditional_malloc_size_of]
|
||||
form_disabled_callback: Option<Rc<Function>>,
|
||||
|
||||
#[ignore_malloc_size_of = "Rc"]
|
||||
#[conditional_malloc_size_of]
|
||||
form_state_restore_callback: Option<Rc<Function>>,
|
||||
}
|
||||
|
||||
|
@ -657,7 +657,7 @@ pub(crate) struct CustomElementDefinition {
|
|||
pub(crate) local_name: LocalName,
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#concept-custom-element-definition-constructor>
|
||||
#[ignore_malloc_size_of = "Rc"]
|
||||
#[conditional_malloc_size_of]
|
||||
pub(crate) constructor: Rc<CustomElementConstructor>,
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#concept-custom-element-definition-observed-attributes>
|
||||
|
@ -988,9 +988,9 @@ pub(crate) fn try_upgrade_element(element: &Element) {
|
|||
#[derive(JSTraceable, MallocSizeOf)]
|
||||
#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
|
||||
pub(crate) enum CustomElementReaction {
|
||||
Upgrade(#[ignore_malloc_size_of = "Rc"] Rc<CustomElementDefinition>),
|
||||
Upgrade(#[conditional_malloc_size_of] Rc<CustomElementDefinition>),
|
||||
Callback(
|
||||
#[ignore_malloc_size_of = "Rc"] Rc<Function>,
|
||||
#[conditional_malloc_size_of] Rc<Function>,
|
||||
#[ignore_malloc_size_of = "mozjs"] Box<[Heap<JSVal>]>,
|
||||
),
|
||||
}
|
||||
|
|
|
@ -163,11 +163,11 @@ static CONTENT_EVENT_HANDLER_NAMES: [&str; 83] = [
|
|||
#[derive(Clone, JSTraceable, MallocSizeOf, PartialEq)]
|
||||
#[allow(clippy::enum_variant_names)]
|
||||
pub(crate) enum CommonEventHandler {
|
||||
EventHandler(#[ignore_malloc_size_of = "Rc"] Rc<EventHandlerNonNull>),
|
||||
EventHandler(#[conditional_malloc_size_of] Rc<EventHandlerNonNull>),
|
||||
|
||||
ErrorEventHandler(#[ignore_malloc_size_of = "Rc"] Rc<OnErrorEventHandlerNonNull>),
|
||||
ErrorEventHandler(#[conditional_malloc_size_of] Rc<OnErrorEventHandlerNonNull>),
|
||||
|
||||
BeforeUnloadEventHandler(#[ignore_malloc_size_of = "Rc"] Rc<OnBeforeUnloadEventHandlerNonNull>),
|
||||
BeforeUnloadEventHandler(#[conditional_malloc_size_of] Rc<OnBeforeUnloadEventHandlerNonNull>),
|
||||
}
|
||||
|
||||
impl CommonEventHandler {
|
||||
|
@ -231,7 +231,7 @@ fn get_compiled_handler(
|
|||
|
||||
#[derive(Clone, JSTraceable, MallocSizeOf, PartialEq)]
|
||||
enum EventListenerType {
|
||||
Additive(#[ignore_malloc_size_of = "Rc"] Rc<EventListener>),
|
||||
Additive(#[conditional_malloc_size_of] Rc<EventListener>),
|
||||
Inline(RefCell<InlineEventListener>),
|
||||
}
|
||||
|
||||
|
@ -439,7 +439,7 @@ impl std::cmp::PartialEq for EventListenerEntry {
|
|||
#[derive(Clone, JSTraceable, MallocSizeOf)]
|
||||
/// A mix of potentially uncompiled and compiled event listeners of the same type.
|
||||
pub(crate) struct EventListeners(
|
||||
#[ignore_malloc_size_of = "Rc"] Vec<Rc<RefCell<EventListenerEntry>>>,
|
||||
#[conditional_malloc_size_of] Vec<Rc<RefCell<EventListenerEntry>>>,
|
||||
);
|
||||
|
||||
impl Deref for EventListeners {
|
||||
|
|
|
@ -361,7 +361,6 @@ pub(crate) struct HTMLInputElement {
|
|||
size: Cell<u32>,
|
||||
maxlength: Cell<i32>,
|
||||
minlength: Cell<i32>,
|
||||
#[ignore_malloc_size_of = "TextInput contains an IPCSender which cannot be measured"]
|
||||
#[no_trace]
|
||||
textinput: DomRefCell<TextInput<EmbedderClipboardProvider>>,
|
||||
// https://html.spec.whatwg.org/multipage/#concept-input-value-dirty-flag
|
||||
|
|
|
@ -111,13 +111,17 @@ static MEDIA_CONTROL_CSS: &str = include_str!("../resources/media-controls.css")
|
|||
/// A JS file to control the media controls.
|
||||
static MEDIA_CONTROL_JS: &str = include_str!("../resources/media-controls.js");
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(MallocSizeOf, PartialEq)]
|
||||
enum FrameStatus {
|
||||
Locked,
|
||||
Unlocked,
|
||||
}
|
||||
|
||||
struct FrameHolder(FrameStatus, VideoFrame);
|
||||
#[derive(MallocSizeOf)]
|
||||
struct FrameHolder(
|
||||
FrameStatus,
|
||||
#[ignore_malloc_size_of = "defined in servo-media"] VideoFrame,
|
||||
);
|
||||
|
||||
impl FrameHolder {
|
||||
fn new(frame: VideoFrame) -> FrameHolder {
|
||||
|
@ -159,6 +163,7 @@ impl FrameHolder {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(MallocSizeOf)]
|
||||
pub(crate) struct MediaFrameRenderer {
|
||||
player_id: Option<u64>,
|
||||
compositor_api: CrossProcessCompositorApi,
|
||||
|
@ -389,7 +394,7 @@ pub(crate) struct HTMLMediaElement {
|
|||
#[ignore_malloc_size_of = "servo_media"]
|
||||
#[no_trace]
|
||||
player: DomRefCell<Option<Arc<Mutex<dyn Player>>>>,
|
||||
#[ignore_malloc_size_of = "Arc"]
|
||||
#[conditional_malloc_size_of]
|
||||
#[no_trace]
|
||||
video_renderer: Arc<Mutex<MediaFrameRenderer>>,
|
||||
#[ignore_malloc_size_of = "Arc"]
|
||||
|
@ -417,7 +422,6 @@ pub(crate) struct HTMLMediaElement {
|
|||
#[no_trace]
|
||||
blob_url: DomRefCell<Option<ServoUrl>>,
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-media-played>
|
||||
#[ignore_malloc_size_of = "Rc"]
|
||||
played: DomRefCell<TimeRangesContainer>,
|
||||
// https://html.spec.whatwg.org/multipage/#dom-media-audiotracks
|
||||
audio_tracks_list: MutNullableDom<AudioTrackList>,
|
||||
|
|
|
@ -50,7 +50,6 @@ use crate::textinput::{
|
|||
#[dom_struct]
|
||||
pub(crate) struct HTMLTextAreaElement {
|
||||
htmlelement: HTMLElement,
|
||||
#[ignore_malloc_size_of = "TextInput contains an IPCSender which cannot be measured"]
|
||||
#[no_trace]
|
||||
textinput: DomRefCell<TextInput<EmbedderClipboardProvider>>,
|
||||
placeholder: DomRefCell<DOMString>,
|
||||
|
|
|
@ -66,7 +66,7 @@ pub(crate) struct ElementRareData {
|
|||
/// <https://html.spec.whatwg.org/multipage/#custom-element-reaction-queue>
|
||||
pub(crate) custom_element_reaction_queue: Vec<CustomElementReaction>,
|
||||
/// <https://dom.spec.whatwg.org/#concept-element-custom-element-definition>
|
||||
#[ignore_malloc_size_of = "Rc"]
|
||||
#[conditional_malloc_size_of]
|
||||
pub(crate) custom_element_definition: Option<Rc<CustomElementDefinition>>,
|
||||
/// <https://dom.spec.whatwg.org/#concept-element-custom-element-state>
|
||||
pub(crate) custom_element_state: CustomElementState,
|
||||
|
|
|
@ -115,17 +115,18 @@ impl Callback for StartAlgorithmRejectionHandler {
|
|||
}
|
||||
|
||||
/// <https://streams.spec.whatwg.org/#value-with-size>
|
||||
#[derive(Debug, JSTraceable, PartialEq)]
|
||||
#[derive(Debug, JSTraceable, MallocSizeOf, PartialEq)]
|
||||
#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
|
||||
pub(crate) struct ValueWithSize {
|
||||
/// <https://streams.spec.whatwg.org/#value-with-size-value>
|
||||
#[ignore_malloc_size_of = "Heap is measured by mozjs"]
|
||||
pub(crate) value: Box<Heap<JSVal>>,
|
||||
/// <https://streams.spec.whatwg.org/#value-with-size-size>
|
||||
pub(crate) size: f64,
|
||||
}
|
||||
|
||||
/// <https://streams.spec.whatwg.org/#value-with-size>
|
||||
#[derive(Debug, JSTraceable, PartialEq)]
|
||||
#[derive(Debug, JSTraceable, MallocSizeOf, PartialEq)]
|
||||
#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
|
||||
pub(crate) enum EnqueuedValue {
|
||||
/// A value enqueued from Rust.
|
||||
|
@ -191,7 +192,6 @@ fn is_non_negative_number(value: &EnqueuedValue) -> bool {
|
|||
#[derive(Default, JSTraceable, MallocSizeOf)]
|
||||
#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
|
||||
pub(crate) struct QueueWithSizes {
|
||||
#[ignore_malloc_size_of = "EnqueuedValue::Js"]
|
||||
queue: VecDeque<EnqueuedValue>,
|
||||
/// <https://streams.spec.whatwg.org/#readablestreamdefaultcontroller-queuetotalsize>
|
||||
pub(crate) total_size: f64,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue