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 378408 f039f3d3d0731522fc2e5143baadb160e34ab23e
parent 378407 5ac03f489657296e2dd989c38e35c96f97d900c1
child 378409 896a380ebbe8889e78e2adbc92647c8738b5ab15
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, jcristau
bugs1338812
milestone53.0a2
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";
@@ -292,29 +292,32 @@ this.MigratorPrototype = {
 
       for (let resourceType of Object.keys(MigrationUtils._importQuantities)) {
         MigrationUtils._importQuantities[resourceType] = 0;
       }
       notify("Migration:Started");
       for (let [migrationType, itemResources] of resourcesGroupedByItems) {
         notify("Migration:ItemBeforeMigrate", migrationType);
 
+        maybeStartTelemetryStopwatch(migrationType);
+
         let itemSuccess = false;
         for (let res of itemResources) {
-          maybeStartTelemetryStopwatch(migrationType, res);
           let completeDeferred = PromiseUtils.defer();
           let resourceDone = function(aSuccess) {
-            maybeStopTelemetryStopwatch(migrationType, res);
             itemResources.delete(res);
             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();
           };