Bug 1538987 - Collect Telemetry on process priority switching. data-review=chutten, r=gsvelto a=pascalc
authorMike Conley <mconley@mozilla.com>
Thu, 28 Mar 2019 14:10:34 +0000
changeset 525910 4a34eea9a8f8314123189ca8ecdb77bf02bd4360
parent 525909 df26e30d2c9e37174c887f2ee15109bd90597ca3
child 525911 0c7eb581b88ee948bf1e3981cef1d18e786b424a
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgsvelto, pascalc
bugs1538987
milestone67.0
Bug 1538987 - Collect Telemetry on process priority switching. data-review=chutten, r=gsvelto a=pascalc Differential Revision: https://phabricator.services.mozilla.com/D25137
dom/ipc/ProcessPriorityManager.cpp
toolkit/components/telemetry/Scalars.yaml
--- a/dom/ipc/ProcessPriorityManager.cpp
+++ b/dom/ipc/ProcessPriorityManager.cpp
@@ -8,16 +8,17 @@
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/TabParent.h"
 #include "mozilla/Hal.h"
 #include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
+#include "mozilla/Telemetry.h"
 #include "mozilla/Unused.h"
 #include "mozilla/Logging.h"
 #include "nsPrintfCString.h"
 #include "nsXULAppAPI.h"
 #include "nsFrameLoader.h"
 #include "nsINamed.h"
 #include "nsIObserverService.h"
 #include "StaticPtr.h"
@@ -488,16 +489,19 @@ void ProcessPriorityManagerImpl::NotifyP
 void ProcessPriorityManagerImpl::TabActivityChanged(TabParent* aTabParent,
                                                     bool aIsActive) {
   RefPtr<ParticularProcessPriorityManager> pppm =
       GetParticularProcessPriorityManager(aTabParent->Manager());
   if (!pppm) {
     return;
   }
 
+  Telemetry::ScalarAdd(
+      Telemetry::ScalarID::DOM_CONTENTPROCESS_OS_PRIORITY_CHANGE_CONSIDERED, 1);
+
   pppm->TabActivityChanged(aTabParent, aIsActive);
 }
 
 NS_IMPL_ISUPPORTS(ParticularProcessPriorityManager, nsIObserver,
                   nsITimerCallback, nsISupportsWeakReference, nsINamed);
 
 ParticularProcessPriorityManager::ParticularProcessPriorityManager(
     ContentParent* aContentParent)
@@ -790,16 +794,25 @@ void ParticularProcessPriorityManager::S
   }
 
   LOGP("Changing priority from %s to %s.", ProcessPriorityToString(mPriority),
        ProcessPriorityToString(aPriority));
 
   ProcessPriority oldPriority = mPriority;
 
   mPriority = aPriority;
+
+  if (oldPriority < mPriority) {
+    Telemetry::ScalarAdd(
+        Telemetry::ScalarID::DOM_CONTENTPROCESS_OS_PRIORITY_RAISED, 1);
+  } else {
+    Telemetry::ScalarAdd(
+        Telemetry::ScalarID::DOM_CONTENTPROCESS_OS_PRIORITY_LOWERED, 1);
+  }
+
   hal::SetProcessPriority(Pid(), mPriority);
 
   if (oldPriority != mPriority) {
     ProcessPriorityManagerImpl::GetSingleton()->NotifyProcessPriorityChanged(
         this, oldPriority);
 
     Unused << mContentParent->SendNotifyProcessPriorityChanged(mPriority);
   }
--- a/toolkit/components/telemetry/Scalars.yaml
+++ b/toolkit/components/telemetry/Scalars.yaml
@@ -1042,16 +1042,59 @@ dom.contentprocess:
       buildID mismatch between the parent and the content processes.
     expires: never
     kind: uint
     notification_emails:
       - spohl@mozilla.com
     release_channel_collection: opt-out
     record_in_processes:
       - 'main'
+  os_priority_lowered:
+    bug_numbers:
+      - 1538987
+    description: >
+      The number of times a content process has had its OS priority lowered
+      due to only containing background tabs without audible media playing.
+    expires: never
+    kind: uint
+    notification_emails:
+      - mconley@mozilla.com
+      - gsvelto@mozilla.com
+    release_channel_collection: opt-out
+    record_in_processes:
+      - 'main'
+  os_priority_raised:
+    bug_numbers:
+      - 1538987
+    description: >
+      The number of times a content process has had its OS priority raised
+      due to containing at least one foregrounded tab, or a tab with audible
+      media has started playing in it.
+    expires: never
+    kind: uint
+    notification_emails:
+      - mconley@mozilla.com
+      - gsvelto@mozilla.com
+    release_channel_collection: opt-out
+    record_in_processes:
+      - 'main'
+  os_priority_change_considered:
+    bug_numbers:
+      - 1538987
+    description: >
+      The number of times we've had the opportunity to change content process
+      priority due to a tab switch or a tab being opened.
+    expires: never
+    kind: uint
+    notification_emails:
+      - mconley@mozilla.com
+      - gsvelto@mozilla.com
+    release_channel_collection: opt-out
+    record_in_processes:
+      - 'main'
 
 # The following section contains parent process base counters.
 dom.parentprocess:
   private_window_used:
     bug_numbers:
       - 1491047
     description: >
       Whether a private browsing window has been used in the session.