Bug 1451005 - Add low commit-space event counts to the memory reporter; r?njn draft
authorGabriele Svelto <gsvelto@mozilla.com>
Wed, 16 May 2018 13:58:10 +0200
changeset 796277 262d60917dbefc35aa6215913e45f7054da6d015
parent 796276 60f1fd814f46bb98da7a5d73e648aeac837fc8b7
child 796278 d2acf821be12d337830344ad7a35565a3619d106
push id110202
push usergsvelto@mozilla.com
push dateThu, 17 May 2018 12:48:51 +0000
reviewersnjn
bugs1451005
milestone62.0a1
Bug 1451005 - Add low commit-space event counts to the memory reporter; r?njn MozReview-Commit-ID: 1jZwxj427tg
toolkit/components/aboutmemory/tests/test_memoryReporters.xul
xpcom/base/AvailableMemoryTracker.cpp
xpcom/base/nsIMemoryReporter.idl
xpcom/base/nsMemoryReporterManager.cpp
xpcom/base/nsMemoryReporterManager.h
--- a/toolkit/components/aboutmemory/tests/test_memoryReporters.xul
+++ b/toolkit/components/aboutmemory/tests/test_memoryReporters.xul
@@ -152,16 +152,17 @@
     "heapOverheadFraction",
     "JSMainRuntimeGCHeap",
     "JSMainRuntimeTemporaryPeak",
     "JSMainRuntimeCompartmentsSystem",
     "JSMainRuntimeCompartmentsUser",
     "imagesContentUsedUncompressed",
     "storageSQLite",
     "lowMemoryEventsVirtual",
+    "lowMemoryEventsCommitSpace",
     "lowMemoryEventsPhysical",
     "ghostWindows",
     "pageFaultsHard",
   ];
   for (let i = 0; i < amounts.length; i++) {
     try {
       // If mgr[amounts[i]] throws an exception, just move on -- some amounts
       // aren't available on all platforms.  But if the attribute simply
--- a/xpcom/base/AvailableMemoryTracker.cpp
+++ b/xpcom/base/AvailableMemoryTracker.cpp
@@ -447,16 +447,22 @@ nsAvailableMemoryWatcher::Observe(nsISup
 
 static int64_t
 LowMemoryEventsVirtualDistinguishedAmount()
 {
   return sNumLowVirtualMemEvents;
 }
 
 static int64_t
+LowMemoryEventsCommitSpaceDistinguishedAmount()
+{
+  return sNumLowCommitSpaceEvents;
+}
+
+static int64_t
 LowMemoryEventsPhysicalDistinguishedAmount()
 {
   return sNumLowPhysicalMemEvents;
 }
 
 class LowEventsReporter final : public nsIMemoryReporter
 {
   ~LowEventsReporter() {}
@@ -473,17 +479,17 @@ public:
 "Number of low-virtual-memory events fired since startup. We fire such an "
 "event if we notice there is less than memory.low_virtual_mem_threshold_mb of "
 "virtual address space available (if zero, this behavior is disabled). The "
 "process will probably crash if it runs out of virtual address space, so "
 "this event is dire.");
 
     MOZ_COLLECT_REPORT(
       "low-memory-events/commit-space", KIND_OTHER, UNITS_COUNT_CUMULATIVE,
-      sNumLowCommitSpaceEvents,
+      LowMemoryEventsCommitSpaceDistinguishedAmount(),
 "Number of low-commit-space events fired since startup. We fire such an "
 "event if we notice there is less than memory.low_commit_space_threshold_mb of "
 "commit space available (if zero, this behavior is disabled). Windows will "
 "likely kill the process if it runs out of commit space, so this event is "
 "dire.");
 
     MOZ_COLLECT_REPORT(
       "low-memory-events/physical", KIND_OTHER, UNITS_COUNT_CUMULATIVE,
--- a/xpcom/base/nsIMemoryReporter.idl
+++ b/xpcom/base/nsIMemoryReporter.idl
@@ -365,19 +365,19 @@ interface nsIMemoryReporterManager : nsI
    * |JSMainRuntimeCompartments{System,User}| (UNITS_COUNT)  The number of
    * {system,user} compartments in the main JS runtime.
    *
    * |imagesContentUsedUncompressed| (UNITS_BYTES)  Memory used for decoded
    * raster images in content.
    *
    * |storageSQLite| (UNITS_BYTES)  Memory used by SQLite.
    *
-   * |lowMemoryEvents{Virtual,Physical}| (UNITS_COUNT_CUMULATIVE)  The number
-   * of low-{virtual,physical}-memory events that have occurred since the
-   * process started.
+   * |lowMemoryEvents{Virtual,CommitSpace,Physical}| (UNITS_COUNT_CUMULATIVE)
+   * The number of low-{virtual,commit-space,physical}-memory events that have
+   * occurred since the process started.
    *
    * |ghostWindows| (UNITS_COUNT)  A cached value of the number of ghost
    * windows. This should have been updated within the past 60s.
    *
    * |pageFaultsHard| (UNITS_COUNT_CUMULATIVE)  The number of hard (a.k.a.
    * major) page faults that have occurred since the process started.
    */
   [must_use] readonly attribute int64_t vsize;
@@ -395,16 +395,17 @@ interface nsIMemoryReporterManager : nsI
   [must_use] readonly attribute int64_t JSMainRuntimeCompartmentsSystem;
   [must_use] readonly attribute int64_t JSMainRuntimeCompartmentsUser;
 
   [must_use] readonly attribute int64_t imagesContentUsedUncompressed;
 
   [must_use] readonly attribute int64_t storageSQLite;
 
   [must_use] readonly attribute int64_t lowMemoryEventsVirtual;
+  [must_use] readonly attribute int64_t lowMemoryEventsCommitSpace;
   [must_use] readonly attribute int64_t lowMemoryEventsPhysical;
 
   [must_use] readonly attribute int64_t ghostWindows;
 
   [must_use] readonly attribute int64_t pageFaultsHard;
 
   /*
    * This attribute indicates if moz_malloc_usable_size() works.
--- a/xpcom/base/nsMemoryReporterManager.cpp
+++ b/xpcom/base/nsMemoryReporterManager.cpp
@@ -2515,16 +2515,22 @@ nsMemoryReporterManager::GetStorageSQLit
 
 NS_IMETHODIMP
 nsMemoryReporterManager::GetLowMemoryEventsVirtual(int64_t* aAmount)
 {
   return GetInfallibleAmount(mAmountFns.mLowMemoryEventsVirtual, aAmount);
 }
 
 NS_IMETHODIMP
+nsMemoryReporterManager::GetLowMemoryEventsCommitSpace(int64_t* aAmount)
+{
+  return GetInfallibleAmount(mAmountFns.mLowMemoryEventsCommitSpace, aAmount);
+}
+
+NS_IMETHODIMP
 nsMemoryReporterManager::GetLowMemoryEventsPhysical(int64_t* aAmount)
 {
   return GetInfallibleAmount(mAmountFns.mLowMemoryEventsPhysical, aAmount);
 }
 
 NS_IMETHODIMP
 nsMemoryReporterManager::GetGhostWindows(int64_t* aAmount)
 {
--- a/xpcom/base/nsMemoryReporterManager.h
+++ b/xpcom/base/nsMemoryReporterManager.h
@@ -144,16 +144,17 @@ public:
     mozilla::InfallibleAmountFn mJSMainRuntimeCompartmentsSystem;
     mozilla::InfallibleAmountFn mJSMainRuntimeCompartmentsUser;
 
     mozilla::InfallibleAmountFn mImagesContentUsedUncompressed;
 
     mozilla::InfallibleAmountFn mStorageSQLite;
 
     mozilla::InfallibleAmountFn mLowMemoryEventsVirtual;
+    mozilla::InfallibleAmountFn mLowMemoryEventsCommitSpace;
     mozilla::InfallibleAmountFn mLowMemoryEventsPhysical;
 
     mozilla::InfallibleAmountFn mGhostWindows;
 
     AmountFns()
     {
       mozilla::PodZero(this);
     }