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:
Josh Matthews 2025-08-20 04:43:58 -04:00 committed by GitHub
parent 604b6ea26d
commit 636e7211e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 44 additions and 38 deletions

View file

@ -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,