Bug 808003 - Add a few telemetry probes to help tune tab zombification parameters. r=gcp, mfinkle
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 07 Nov 2012 10:00:48 -0500
changeset 112538 4f5f601bc7413cbc20860e45cfc6bb79f1819871
parent 112537 03393060a0704a5bfe95e4a45f4641dabd100943
child 112539 cbafefd68d1c5449ce25d74df95c43e6a6550f86
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersgcp, mfinkle
bugs808003
milestone19.0a1
Bug 808003 - Add a few telemetry probes to help tune tab zombification parameters. r=gcp, mfinkle
mobile/android/chrome/content/browser.js
toolkit/components/telemetry/Histograms.json
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -7604,22 +7604,23 @@ var MemoryObserver = {
 
   handleLowMemory: function() {
     // do things to reduce memory usage here
     let tabs = BrowserApp.tabs;
     let selected = BrowserApp.selectedTab;
     for (let i = 0; i < tabs.length; i++) {
       if (tabs[i] != selected) {
         this.zombify(tabs[i]);
-      }
-    }
+        Telemetry.addData("FENNEC_TAB_ZOMBIFIED", (Date.now() - tabs[i].lastTouchedAt) / 1000);
+      }
+    }
+    Telemetry.addData("FENNEC_LOWMEM_TAB_COUNT", tabs.length);
   },
 
   zombify: function(tab) {
-    dump("Zombifying tab at index [" + tab.id + "]");
     let browser = tab.browser;
     let data = browser.__SS_data;
     let extra = browser.__SS_extdata;
 
     // We need this data to correctly create and position the new browser
     // If this browser is already a zombie, fallback to the session data
     let currentURL = browser.__SS_restore ? data.entries[0].url : browser.currentURI.spec;
     let sibling = browser.nextSibling;
@@ -7766,18 +7767,20 @@ var Tabs = {
         continue;
       }
       if (lruTab == null || tabs[i].lastTouchedAt < lruTab.lastTouchedAt) {
         lruTab = tabs[i];
       }
     }
     // if the tab was last touched more than browser.tabs.expireTime seconds ago,
     // zombify it
-    if (lruTab && (Date.now() - lruTab.lastTouchedAt) > expireTimeMs) {
+    let tabAgeMs = Date.now() - lruTab.lastTouchedAt;
+    if (lruTab && tabAgeMs > expireTimeMs) {
       MemoryObserver.zombify(lruTab);
+      Telemetry.addData("FENNEC_TAB_EXPIRED", tabAgeMs / 1000);
       return true;
     }
     return false;
   },
 
   // for debugging
   dump: function(aPrefix) {
     let tabs = BrowserApp.tabs;
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -2304,16 +2304,23 @@
   "FENNEC_AWESOMEBAR_ALLPAGES_EMPTY_TIME": {
     "kind": "exponential",
     "low": 10,
     "high": "20000",
     "n_buckets": 20,
     "description": "Fennec: Time for the Awesomebar Top Sites query to return with no filter set (ms)",
     "cpp_guard": "ANDROID"
   },
+  "FENNEC_LOWMEM_TAB_COUNT": {
+    "kind": "exponential",
+    "high": 100,
+    "n_buckets": 30,
+    "description": "How many tabs were open when a low-memory event was received",
+    "cpp_guard": "ANDROID"
+  },
   "FENNEC_RESTORING_ACTIVITY": {
     "kind": "flag",
     "description": "Fennec is starting up but the Gecko thread was still running",
     "cpp_guard": "ANDROID"
   },
   "FENNEC_STARTUP_TIME_JAVAUI": {
     "kind": "exponential",
     "low": 100,
@@ -2339,16 +2346,32 @@
     "cpp_guard": "ANDROID"
   },
   "FENNEC_STARTUP_GECKOAPP_ACTION": {
     "kind": "enumerated",
     "n_values": 4,
     "description": "The way the GeckoApp was launched. (Normal, URL, Prefetch, Redirector)",
     "cpp_guard": "ANDROID"
   },
+  "FENNEC_TAB_EXPIRED": {
+    "kind": "exponential",
+    "low": 10,
+    "high": 604800,
+    "n_buckets": 20,
+    "description": "How long (in seconds) a tab was inactive before it was expired",
+    "cpp_guard": "ANDROID"
+  },
+  "FENNEC_TAB_ZOMBIFIED": {
+    "kind": "exponential",
+    "low": 10,
+    "high": 1000000,
+    "n_buckets": 20,
+    "description": "How long (in seconds) a tab was inactive when it was OOM-zombified",
+    "cpp_guard": "ANDROID"
+  },
   "FENNEC_WAS_KILLED": {
     "kind": "flag",
     "description": "Killed, likely due to an OOM condition",
     "cpp_guard": "ANDROID"
   },
   "SECURITY_UI": {
     "kind": "enumerated",
     "n_values": 100,