Bug 1338812 - Call TelemetryStopwatch only once per item (history / bookmarks / logins) rather than for each resource. r=Gijs, a=jcristau
authorDão Gottwald <dao@mozilla.com>
Sat, 11 Feb 2017 21:14:52 +0100
changeset 367071 4ad8573642c78523c549e9ee3b90c24f9a464834
parent 367070 b000e60212be6963d7edba66a52914d575efcbbc
child 367074 bd9cd325c4bca4a9f0256d9300c7ac00dd9bf7a8
push id6920
push userryanvm@gmail.com
push dateMon, 13 Feb 2017 18:24:14 +0000
treeherdermozilla-beta@4ad8573642c7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, jcristau
bugs1338812
milestone52.0
Bug 1338812 - Call TelemetryStopwatch only once per item (history / bookmarks / logins) rather than for each resource. r=Gijs, a=jcristau MozReview-Commit-ID: 7c5DgKDIFTv
browser/components/migration/MigrationUtils.jsm
--- a/browser/components/migration/MigrationUtils.jsm
+++ b/browser/components/migration/MigrationUtils.jsm
@@ -244,26 +244,26 @@ this.MigratorPrototype = {
       if (resourceType == MigrationUtils.resourceTypes.BOOKMARKS) {
         return "FX_MIGRATION_BOOKMARKS_IMPORT_MS";
       }
       if (resourceType == MigrationUtils.resourceTypes.PASSWORDS) {
         return "FX_MIGRATION_LOGINS_IMPORT_MS";
       }
       return null;
     };
-    let maybeStartTelemetryStopwatch = (resourceType, resource) => {
+    let maybeStartTelemetryStopwatch = (resourceType) => {
       let histogram = getHistogramForResourceType(resourceType);
       if (histogram) {
-        TelemetryStopwatch.startKeyed(histogram, this.getKey(), resource);
+        TelemetryStopwatch.startKeyed(histogram, this.getKey());
       }
     };
-    let maybeStopTelemetryStopwatch = (resourceType, resource) => {
+    let maybeStopTelemetryStopwatch = (resourceType) => {
       let histogram = getHistogramForResourceType(resourceType);
       if (histogram) {
-        TelemetryStopwatch.finishKeyed(histogram, this.getKey(), resource);
+        TelemetryStopwatch.finishKeyed(histogram, this.getKey());
       }
     };
 
     let collectQuantityTelemetry = () => {
       try {
         for (let resourceType of Object.keys(MigrationUtils._importQuantities)) {
           let histogramId =
             "FX_MIGRATION_" + resourceType.toUpperCase() + "_QUANTITY";
@@ -295,31 +295,34 @@ this.MigratorPrototype = {
       }
       notify("Migration:Started");
       for (let [key, value] of resourcesGroupedByItems) {
         // Workaround bug 449811.
         let migrationType = key, itemResources = value;
 
         notify("Migration:ItemBeforeMigrate", migrationType);
 
+        maybeStartTelemetryStopwatch(migrationType);
+
         let itemSuccess = false;
         for (let res of itemResources) {
           // Workaround bug 449811.
           let resource = res;
-          maybeStartTelemetryStopwatch(migrationType, resource);
           let completeDeferred = PromiseUtils.defer();
           let resourceDone = function(aSuccess) {
-            maybeStopTelemetryStopwatch(migrationType, resource);
             itemResources.delete(resource);
             itemSuccess |= aSuccess;
             if (itemResources.size == 0) {
               notify(itemSuccess ?
                      "Migration:ItemAfterMigrate" : "Migration:ItemError",
                      migrationType);
               resourcesGroupedByItems.delete(migrationType);
+
+              maybeStopTelemetryStopwatch(migrationType);
+
               if (resourcesGroupedByItems.size == 0) {
                 collectQuantityTelemetry();
                 notify("Migration:Ended");
               }
             }
             completeDeferred.resolve();
           };