bug 1405299 - Key loadArchivedPing's stopwatches for re-entrancy r=Dexter
authorChris H-C <chutten@mozilla.com>
Wed, 11 Oct 2017 12:53:37 -0400
changeset 385888 f2390464f1ef86d3a53e11ec20c038e9b9281606
parent 385887 ec713e74ec142311fd3ce2a9ea027d8f9063e69c
child 385889 0fd360d7ba33e0f46406815b28d01ce466c2cfff
push id32672
push userarchaeopteryx@coole-files.de
push dateFri, 13 Oct 2017 09:00:05 +0000
treeherdermozilla-central@3efcb26e5f37 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersDexter
bugs1405299
milestone58.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 1405299 - Key loadArchivedPing's stopwatches for re-entrancy r=Dexter loadArchivedPing is asynchronous, so it may be re-entrant. Key the stopwatches against the ping id so it measures what it should and stops complaining. MozReview-Commit-ID: GdHH5N8B4V7
toolkit/components/telemetry/TelemetryStorage.jsm
--- a/toolkit/components/telemetry/TelemetryStorage.jsm
+++ b/toolkit/components/telemetry/TelemetryStorage.jsm
@@ -698,58 +698,59 @@ var TelemetryStorageImpl = {
 
   /**
    * Load an archived ping from disk.
    *
    * @param {string} id The pings id.
    * @return {promise<object>} Promise that is resolved with the ping data.
    */
   async loadArchivedPing(id) {
-    TelemetryStopwatch.start("TELEMETRY_ARCHIVE_LOAD_MS");
+    let idAsObject = {id};
+    TelemetryStopwatch.start("TELEMETRY_ARCHIVE_LOAD_MS", idAsObject);
     const data = this._archivedPings.get(id);
     if (!data) {
-      TelemetryStopwatch.cancel("TELEMETRY_ARCHIVE_LOAD_MS");
+      TelemetryStopwatch.cancel("TELEMETRY_ARCHIVE_LOAD_MS", idAsObject);
       this._log.trace("loadArchivedPing - no ping with id: " + id);
       return Promise.reject(new Error("TelemetryStorage.loadArchivedPing - no ping with id " + id));
     }
 
     const path = getArchivedPingPath(id, new Date(data.timestampCreated), data.type);
     const pathCompressed = path + "lz4";
 
     // Purge pings which are too big.
     let checkSize = async function(path) {
       const fileSize = (await OS.File.stat(path)).size;
       if (fileSize > PING_FILE_MAXIMUM_SIZE_BYTES) {
         Telemetry.getHistogramById("TELEMETRY_DISCARDED_ARCHIVED_PINGS_SIZE_MB")
                  .add(Math.floor(fileSize / 1024 / 1024));
         Telemetry.getHistogramById("TELEMETRY_PING_SIZE_EXCEEDED_ARCHIVED").add();
-        TelemetryStopwatch.cancel("TELEMETRY_ARCHIVE_LOAD_MS");
+        TelemetryStopwatch.cancel("TELEMETRY_ARCHIVE_LOAD_MS", idAsObject);
         await OS.File.remove(path, {ignoreAbsent: true});
         throw new Error("loadArchivedPing - exceeded the maximum ping size: " + fileSize);
       }
     };
 
     let ping;
     try {
       // Try to load a compressed version of the archived ping first.
       this._log.trace("loadArchivedPing - loading ping from: " + pathCompressed);
       await checkSize(pathCompressed);
       ping = await this.loadPingFile(pathCompressed, /* compressed*/ true);
     } catch (ex) {
       if (!ex.becauseNoSuchFile) {
-        TelemetryStopwatch.cancel("TELEMETRY_ARCHIVE_LOAD_MS");
+        TelemetryStopwatch.cancel("TELEMETRY_ARCHIVE_LOAD_MS", idAsObject);
         throw ex;
       }
       // If that fails, look for the uncompressed version.
       this._log.trace("loadArchivedPing - compressed ping not found, loading: " + path);
       await checkSize(path);
       ping = await this.loadPingFile(path, /* compressed*/ false);
     }
 
-    TelemetryStopwatch.finish("TELEMETRY_ARCHIVE_LOAD_MS");
+    TelemetryStopwatch.finish("TELEMETRY_ARCHIVE_LOAD_MS", idAsObject);
     return ping;
   },
 
   /**
    * Saves session data to disk.
    */
   saveSessionData(sessionData) {
     return this._stateSaveSerializer.enqueueTask(() => this._saveSessionData(sessionData));