Bug 1397472 - Measure ElementData. r=bholley.
authorNicholas Nethercote <nnethercote@mozilla.com>
Sat, 09 Sep 2017 00:12:25 +1000
changeset 429372 8f53032e5451db68972e8aaeb6a394c4c271073a
parent 429371 be66eb2bb0d83a1899e3dd99298a6e994a7d3461
child 429373 9a3854a56016ce423ecccf4f03ca35b50218452d
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1397472
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1397472 - Measure ElementData. r=bholley. We already measure (in Rust code) the things hanging off it, but overlooked the object itself. This patch adds measurement on the C++ side.
dom/base/Element.cpp
dom/base/nsWindowMemoryReporter.cpp
dom/base/nsWindowSizes.h
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -4216,19 +4216,23 @@ Element::SetCustomElementData(CustomElem
 MOZ_DEFINE_MALLOC_SIZE_OF(ServoElementMallocSizeOf)
 
 void
 Element::AddSizeOfExcludingThis(nsWindowSizes& aSizes, size_t* aNodeSize) const
 {
   FragmentOrElement::AddSizeOfExcludingThis(aSizes, aNodeSize);
 
   if (HasServoData()) {
+    // Measure the ElementData object itself.
+    aSizes.mLayoutServoElementDataObjects +=
+      aSizes.mState.mMallocSizeOf(mServoData.Get());
+
     // Measure mServoData, excluding the ComputedValues. This measurement
     // counts towards the element's size. We use ServoElementMallocSizeOf
-    // rather thang |aState.mMallocSizeOf| to better distinguish in DMD's
+    // rather than |aState.mMallocSizeOf| to better distinguish in DMD's
     // output the memory measured within Servo code.
     *aNodeSize +=
       Servo_Element_SizeOfExcludingThisAndCVs(ServoElementMallocSizeOf,
                                               &aSizes.mState.mSeenPtrs, this);
 
     // Now measure just the ComputedValues (and style structs) under
     // mServoData. This counts towards the relevant fields in |aSizes|.
     RefPtr<ServoStyleContext> sc;
--- a/dom/base/nsWindowMemoryReporter.cpp
+++ b/dom/base/nsWindowMemoryReporter.cpp
@@ -413,16 +413,23 @@ CollectWindowReports(nsGlobalWindow *aWi
 
   REPORT_SIZE("/layout/servo-style-sets/other",
               windowSizes.mLayoutServoStyleSetsOther,
               "Memory used by other parts of Servo style sets within a "
               "window.");
   aWindowTotalSizes->mLayoutServoStyleSetsOther +=
     windowSizes.mLayoutServoStyleSetsOther;
 
+  REPORT_SIZE("/layout/servo-element-data-objects",
+              windowSizes.mLayoutServoElementDataObjects,
+              "Memory used for Servo ElementData objects, but not the things"
+              "hanging off them.");
+  aWindowTotalSizes->mLayoutServoElementDataObjects +=
+    windowSizes.mLayoutServoElementDataObjects;
+
   REPORT_SIZE("/layout/text-runs", windowSizes.mLayoutTextRunsSize,
               "Memory used for text-runs (glyph layout) in the PresShell's "
               "frame tree, within a window.");
   aWindowTotalSizes->mLayoutTextRunsSize += windowSizes.mLayoutTextRunsSize;
 
   REPORT_SIZE("/layout/pres-contexts", windowSizes.mLayoutPresContextSize,
               "Memory used for the PresContext in the PresShell's frame "
               "within a window.");
@@ -709,16 +716,20 @@ nsWindowMemoryReporter::CollectReports(n
          windowTotalSizes.mLayoutServoStyleSetsStylistPrecomputedPseudos +
          windowTotalSizes.mLayoutServoStyleSetsStylistElementAndPseudosMaps +
          windowTotalSizes.mLayoutServoStyleSetsStylistInvalidationMap +
          windowTotalSizes.mLayoutServoStyleSetsStylistRevalidationSelectors +
          windowTotalSizes.mLayoutServoStyleSetsStylistOther +
          windowTotalSizes.mLayoutServoStyleSetsOther,
          "This is the sum of all windows' 'layout/servo-style-sets/' numbers.");
 
+  REPORT("window-objects/layout/servo-element-data-objects",
+         windowTotalSizes.mLayoutServoElementDataObjects,
+         "This is the sum of all windows' 'layout/servo-element-data-objects' "
+         "numbers.");
 
   REPORT("window-objects/layout/text-runs", windowTotalSizes.mLayoutTextRunsSize,
          "This is the sum of all windows' 'layout/text-runs' numbers.");
 
   REPORT("window-objects/layout/pres-contexts",
          windowTotalSizes.mLayoutPresContextSize,
          "This is the sum of all windows' 'layout/pres-contexts' numbers.");
 
--- a/dom/base/nsWindowSizes.h
+++ b/dom/base/nsWindowSizes.h
@@ -178,16 +178,17 @@ class nsWindowSizes
   macro(Style, mLayoutGeckoStyleSets) \
   macro(Style, mLayoutServoStyleSetsStylistRuleTree) \
   macro(Style, mLayoutServoStyleSetsStylistPrecomputedPseudos) \
   macro(Style, mLayoutServoStyleSetsStylistElementAndPseudosMaps) \
   macro(Style, mLayoutServoStyleSetsStylistInvalidationMap) \
   macro(Style, mLayoutServoStyleSetsStylistRevalidationSelectors) \
   macro(Style, mLayoutServoStyleSetsStylistOther) \
   macro(Style, mLayoutServoStyleSetsOther) \
+  macro(Style, mLayoutServoElementDataObjects) \
   macro(Other, mLayoutTextRunsSize) \
   macro(Other, mLayoutPresContextSize) \
   macro(Other, mLayoutFramePropertiesSize) \
   macro(Style, mLayoutComputedValuesDom) \
   macro(Style, mLayoutComputedValuesNonDom) \
   macro(Style, mLayoutComputedValuesVisited) \
   macro(Other, mPropertyTablesSize) \