Bug 1338812 - Call TelemetryStopwatch only once per item (history / bookmarks / logins) rather than for each resource. r=Gijs
authorDão Gottwald <dao@mozilla.com>
Sat, 11 Feb 2017 21:14:52 +0100
changeset 342416 80d9bac9ec223f127f8c92f375287bf4dd8dcd1d
parent 342415 7a024b0cedfc70e3bab54a9dfcb5c388f477c312
child 342417 faba0400cbe2c88149122071fb4bdab6b70939a4
push id31352
push userphilringnalda@gmail.com
push dateSun, 12 Feb 2017 22:50:41 +0000
treeherdermozilla-central@43270c88b251 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1338812
milestone54.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 1338812 - Call TelemetryStopwatch only once per item (history / bookmarks / logins) rather than for each resource. r=Gijs 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();
           };