Bug 1305444 - Move telemetry assignment, remove variable use; r=Yoric
☠☠ backed out by 8c84b7618840 ☠ ☠
authorGregory Szorc <gps@mozilla.com>
Sat, 24 Sep 2016 17:18:21 -0700
changeset 315388 5ef08ec39cd74f6572442b32dc8677a12040a70a
parent 315387 aed585286446d6d39996d8c878a6ccabdef0d4f5
child 315389 87ebfcabb99ac1d7f85b10a595331377cbc3be2e
push id30748
push usercbook@mozilla.com
push dateWed, 28 Sep 2016 13:53:19 +0000
treeherdermozilla-central@8c84b7618840 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersYoric
bugs1305444
milestone52.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 1305444 - Move telemetry assignment, remove variable use; r=Yoric We have an unused "telemetry" variable. Use this variable and move the telemetry assignment to immediately after the operation it is recording. While I was here, I also cleaned up the timing variables. I eliminated the end time variable and moved the declaration of the start time variable so its scope is shorter. MozReview-Commit-ID: IbGOK5pPkcR
browser/components/sessionstore/SessionWorker.js
--- a/browser/components/sessionstore/SessionWorker.js
+++ b/browser/components/sessionstore/SessionWorker.js
@@ -145,34 +145,33 @@ var Agent = {
           tab.entries = tab.entries.slice(lower, upper);
           tab.index -= lower;
         }
       }
     }
 
     let stateString = JSON.stringify(state);
     let data = Encoder.encode(stateString);
-    let startWriteMs, stopWriteMs;
 
     try {
 
       if (this.state == STATE_CLEAN || this.state == STATE_EMPTY) {
         // The backups directory may not exist yet. In all other cases,
         // we have either already read from or already written to this
         // directory, so we are satisfied that it exists.
         File.makeDir(this.Paths.backups);
       }
 
       if (this.state == STATE_CLEAN) {
         // Move $Path.clean out of the way, to avoid any ambiguity as
         // to which file is more recent.
         File.move(this.Paths.clean, this.Paths.cleanBackup);
       }
 
-      startWriteMs = Date.now();
+      let startWriteMs = Date.now();
 
       if (options.isFinalWrite) {
         // We are shutting down. At this stage, we know that
         // $Paths.clean is either absent or corrupted. If it was
         // originally present and valid, it has been moved to
         // $Paths.cleanBackup a long time ago. We can therefore write
         // with the guarantees that we erase no important data.
         File.writeAtomic(this.Paths.clean, data, {
@@ -193,17 +192,18 @@ var Agent = {
         // In other cases, either $Path.recovery is not necessary, or
         // it doesn't exist or it has been corrupted. Regardless,
         // don't backup $Path.recovery.
         File.writeAtomic(this.Paths.recovery, data, {
           tmpPath: this.Paths.recovery + ".tmp"
         });
       }
 
-      stopWriteMs = Date.now();
+      telemetry[FX_SESSION_RESTORE_WRITE_FILE_MS] = Date.now() - startWriteMs;
+      telemetry[FX_SESSION_RESTORE_FILE_SIZE_BYTES] = data.byteLength;
 
     } catch (ex) {
       // Don't throw immediately
       exn = exn || ex;
     }
 
     // If necessary, perform an upgrade backup
     let upgradeBackupComplete = false;
@@ -271,20 +271,17 @@ var Agent = {
     if (exn) {
       throw exn;
     }
 
     return {
       result: {
         upgradeBackup: upgradeBackupComplete
       },
-      telemetry: {
-        FX_SESSION_RESTORE_WRITE_FILE_MS: stopWriteMs - startWriteMs,
-        FX_SESSION_RESTORE_FILE_SIZE_BYTES: data.byteLength,
-      }
+      telemetry: telemetry,
     };
   },
 
   /**
    * Wipes all files holding session data from disk.
    */
   wipe: function () {