Bug 1454724 - Add scalar telemetry for max ghost windows. r=chutten draft
authorAndrew McCreight <continuation@gmail.com>
Wed, 18 Apr 2018 11:56:53 -0700
changeset 784621 00bc8a998038dcd175997e9cc0a0fca749377959
parent 784524 0e45c13b34e815cb42a9f08bb44142d1a81e186e
child 785826 04aa31841b6690d0216c10d038a6f706f027a25d
push id106992
push userbmo:continuation@gmail.com
push dateWed, 18 Apr 2018 21:47:10 +0000
reviewerschutten
bugs1454724
milestone61.0a1
Bug 1454724 - Add scalar telemetry for max ghost windows. r=chutten Rather than recording how many leaked (ghost) windows we see at various times, I think it will be more useful over all to record what the maximum number of ghost windows we see during a single ping. Hopefully this will show up in a way that generates automated alerts better than GHOST_WINDOWS. If this works out, I'll make this telemetry measure permanent and remove GHOST_WINDOWS. MozReview-Commit-ID: 11ma1lLGz5L
dom/base/nsWindowMemoryReporter.cpp
toolkit/components/telemetry/Scalars.yaml
--- a/dom/base/nsWindowMemoryReporter.cpp
+++ b/dom/base/nsWindowMemoryReporter.cpp
@@ -8,16 +8,17 @@
 #include "nsWindowSizes.h"
 #include "nsGlobalWindow.h"
 #include "nsIDocument.h"
 #include "nsIDOMWindowCollection.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 #include "mozilla/StaticPtr.h"
+#include "mozilla/Telemetry.h"
 #include "nsNetCID.h"
 #include "nsPrintfCString.h"
 #include "XPCJSMemoryReporter.h"
 #include "js/MemoryMetrics.h"
 #include "nsQueryObject.h"
 #include "nsServiceManagerUtils.h"
 #ifdef MOZ_XUL
 #include "nsXULPrototypeCache.h"
@@ -895,16 +896,19 @@ nsWindowMemoryReporter::CheckForGhostWin
         // that is not null.
         mGhostWindowCount++;
         if (aOutGhostIDs && window) {
           aOutGhostIDs->PutEntry(window->WindowID());
         }
       }
     }
   }
+
+  Telemetry::ScalarSetMaximum(Telemetry::ScalarID::MEMORYREPORTER_MAX_GHOST_WINDOWS,
+                              mGhostWindowCount);
 }
 
 /* static */ int64_t
 nsWindowMemoryReporter::GhostWindowsDistinguishedAmount()
 {
   return sWindowReporter->mGhostWindowCount;
 }
 
--- a/toolkit/components/telemetry/Scalars.yaml
+++ b/toolkit/components/telemetry/Scalars.yaml
@@ -1617,16 +1617,31 @@ browser.errors:
     expires: "64"
     kind: uint
     notification_emails:
       - nightly-js-errors@mozilla.com
       - mkelly@mozilla.com
     record_in_processes:
       - 'main'
 
+# The following section contains memory reporter counters.
+memoryreporter:
+  max_ghost_windows:
+    bug_numbers:
+      - 1454724
+    description: >
+      The maximum number of leaked ghost windows seen.
+    expires: "66"
+    kind: uint
+    notification_emails:
+      - memshrink-telemetry-alerts@mozilla.com
+    release_channel_collection: opt-out
+    record_in_processes:
+      - 'content'
+
 # The following section is for probes testing the Telemetry system. They will not be
 # submitted in pings and are only used for testing.
 telemetry.test:
   unsigned_int_kind:
     bug_numbers:
       - 1276190
     description: >
       This is a test uint type with a really long description, maybe spanning even multiple