Bug 1464773 - Add low-memory event counts to the crash report; r=ted.mielczarek
authorGabriele Svelto <gsvelto@mozilla.com>
Mon, 28 May 2018 10:09:20 +0200
changeset 421220 fb19935b19308a37eccdbd956dc1f6d26ca038dc
parent 421219 41a29773d7a55a37c9d9d5e6a5bc48c5f005602d
child 421221 98956646c3aac378734fd0c394570fd786bcb02b
push id103992
push userdluca@mozilla.com
push dateMon, 04 Jun 2018 18:57:34 +0000
treeherdermozilla-inbound@425c5899aa74 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs1464773
milestone62.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 1464773 - Add low-memory event counts to the crash report; r=ted.mielczarek MozReview-Commit-ID: 9hf31FSigrI
mobile/android/base/java/org/mozilla/gecko/telemetry/pingbuilders/TelemetryCrashPingBuilder.java
toolkit/components/crashes/CrashManager.jsm
toolkit/components/telemetry/docs/data/crash-ping.rst
toolkit/crashreporter/client/ping.cpp
xpcom/base/AvailableMemoryTracker.cpp
--- a/mobile/android/base/java/org/mozilla/gecko/telemetry/pingbuilders/TelemetryCrashPingBuilder.java
+++ b/mobile/android/base/java/org/mozilla/gecko/telemetry/pingbuilders/TelemetryCrashPingBuilder.java
@@ -44,16 +44,17 @@ public class TelemetryCrashPingBuilder e
         "BlockedDllList",
         "BlocklistInitFailed",
         "BuildID",
         "ContainsMemoryReport",
         "CrashTime",
         "EventLoopNestingLevel",
         "ipc_channel_error",
         "IsGarbageCollecting",
+        "LowCommitSpaceEvents",
         "MozCrashReason",
         "OOMAllocationSize",
         "ProductID",
         "ProductName",
         "ReleaseChannel",
         "RemoteType",
         "SecondsSinceLastCrash",
         "ShutdownProgress",
--- a/toolkit/components/crashes/CrashManager.jsm
+++ b/toolkit/components/crashes/CrashManager.jsm
@@ -222,16 +222,17 @@ this.CrashManager.prototype = Object.fre
   EVENT_FILE_ERROR_UNKNOWN_EVENT: "unknown-event",
 
   // A whitelist of crash annotations which do not contain sensitive data
   // and are saved in the crash record and sent with Firefox Health Report.
   ANNOTATION_WHITELIST: [
     "AsyncShutdownTimeout",
     "BuildID",
     "ipc_channel_error",
+    "LowCommitSpaceEvents",
     "ProductID",
     "ProductName",
     "ReleaseChannel",
     "RemoteType",
     "SecondsSinceLastCrash",
     "ShutdownProgress",
     "StartupCrash",
     "TelemetryEnvironment",
--- a/toolkit/components/telemetry/docs/data/crash-ping.rst
+++ b/toolkit/components/telemetry/docs/data/crash-ping.rst
@@ -56,16 +56,17 @@ Structure:
           AvailableVirtualMemory: <size>, // Windows-only, available virtual memory in bytes
           BlockedDllList: <list>, // Windows-only, see WindowsDllBlocklist.cpp for details
           BlocklistInitFailed: "1", // Windows-only, present only if the DLL blocklist initialization failed
           CrashTime: <time>, // Seconds since the Epoch
           ContainsMemoryReport: "1", // Optional, if set indicates that the crash had a memory report attached
           EventLoopNestingLevel: <levels>, // Optional, present only if >0, indicates the nesting level of the event-loop
           ipc_channel_error: <error string>, // Optional, contains the string processing error reason for an ipc-based content crash
           IsGarbageCollecting: "1", // Optional, if set indicates that the crash occurred while the garbage collector was running
+          LowCommitSpaceEvents: <num>, // Windows-only, present only if >0, number of low commit space events detected by the available memory tracker
           MozCrashReason: <reason>, // Optional, contains the string passed to MOZ_CRASH()
           OOMAllocationSize: <size>, // Size of the allocation that caused an OOM
           RemoteType: <type>, // Optional, type of content process, see below for a list of types
           SecondsSinceLastCrash: <duration>, // Seconds elapsed since the last crash occurred
           ShutdownProgress: <phase>, // Optional, contains a string describing the shutdown phase in which the crash occurred
           SystemMemoryUsePercentage: <percentage>, // Windows-only, percent of memory in use
           StartupCrash: "1", // Optional, if set indicates that Firefox crashed during startup
           TelemetrySessionId: <id>, // Active telemetry session ID when the crash was recorded
--- a/toolkit/crashreporter/client/ping.cpp
+++ b/toolkit/crashreporter/client/ping.cpp
@@ -129,16 +129,17 @@ CreateMetadataNode(StringTable& strings)
     "BlockedDllList",
     "BlocklistInitFailed",
     "BuildID",
     "ContainsMemoryReport",
     "CrashTime",
     "EventLoopNestingLevel",
     "ipc_channel_error",
     "IsGarbageCollecting",
+    "LowCommitSpaceEvents",
     "MozCrashReason",
     "OOMAllocationSize",
     "ProductID",
     "ProductName",
     "ReleaseChannel",
     "RemoteType",
     "SecondsSinceLastCrash",
     "ShutdownProgress",
--- a/xpcom/base/AvailableMemoryTracker.cpp
+++ b/xpcom/base/AvailableMemoryTracker.cpp
@@ -4,18 +4,20 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/AvailableMemoryTracker.h"
 
 #if defined(XP_WIN)
 #include "prinrval.h"
 #include "prenv.h"
+#include "nsExceptionHandler.h"
 #include "nsIMemoryReporter.h"
 #include "nsMemoryPressure.h"
+#include "nsPrintfCString.h"
 #endif
 
 #include "nsIObserver.h"
 #include "nsIObserverService.h"
 #include "nsIRunnable.h"
 #include "nsISupports.h"
 #include "nsITimer.h"
 #include "nsThreadUtils.h"
@@ -350,16 +352,19 @@ nsAvailableMemoryWatcher::IsVirtualMemor
 }
 
 /* static */ bool
 nsAvailableMemoryWatcher::IsCommitSpaceLow(const MEMORYSTATUSEX& aStat)
 {
   if ((kLowCommitSpaceThreshold != 0) &&
       (aStat.ullAvailPageFile < kLowCommitSpaceThreshold)) {
     sNumLowCommitSpaceEvents++;
+    CrashReporter::AnnotateCrashReport(
+      NS_LITERAL_CSTRING("LowCommitSpaceEvents"),
+      nsPrintfCString("%" PRIu32, uint32_t(sNumLowCommitSpaceEvents)));
     return true;
   }
 
   return false;
 }
 
 /* static */ bool
 nsAvailableMemoryWatcher::IsPhysicalMemoryLow(const MEMORYSTATUSEX& aStat)