Bug 1291821 - Switch stage duration interval counting to use elapsedRealtime r=rnewman
authorGrisha Kruglov <gkruglov@mozilla.com>
Sat, 08 Oct 2016 15:28:14 -0700
changeset 344860 e41e4bbf72ab1283f7ab13d0d8e1b20b7dadcbe5
parent 344859 86bc523c8c6024f4f8737813498e994c53625a87
child 344861 07c5a4e937382e86f6baf393626f9c3dd060010a
push id37970
push usergkruglov@mozilla.com
push dateSat, 25 Feb 2017 01:09:28 +0000
treeherderautoland@bd232d46a396 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman
bugs1291821
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 1291821 - Switch stage duration interval counting to use elapsedRealtime r=rnewman It is a better fit for interval counting. MozReview-Commit-ID: LCF0U24MAwF
mobile/android/services/src/main/java/org/mozilla/gecko/sync/stage/ServerSyncStage.java
--- a/mobile/android/services/src/main/java/org/mozilla/gecko/sync/stage/ServerSyncStage.java
+++ b/mobile/android/services/src/main/java/org/mozilla/gecko/sync/stage/ServerSyncStage.java
@@ -1,15 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.sync.stage;
 
 import android.content.Context;
+import android.os.SystemClock;
 
 import org.mozilla.gecko.background.common.log.Logger;
 import org.mozilla.gecko.sync.EngineSettings;
 import org.mozilla.gecko.sync.GlobalSession;
 import org.mozilla.gecko.sync.HTTPFailureException;
 import org.mozilla.gecko.sync.MetaGlobalException;
 import org.mozilla.gecko.sync.NoCollectionKeysSetException;
 import org.mozilla.gecko.sync.NonObjectJSONException;
@@ -470,17 +471,17 @@ public abstract class ServerSyncStage ex
     Logger.info(LOG_TAG, "Wiping server complete.");
   }
 
   @Override
   public void execute() throws NoSuchStageException {
     final String name = getEngineName();
     Logger.debug(LOG_TAG, "Starting execute for " + name);
 
-    stageStartTimestamp = System.currentTimeMillis();
+    stageStartTimestamp = SystemClock.elapsedRealtime();
 
     try {
       if (!this.isEnabled()) {
         Logger.info(LOG_TAG, "Skipping stage " + name + ".");
         session.advance();
         return;
       }
     } catch (MetaGlobalException.MetaGlobalMalformedSyncIDException e) {
@@ -570,17 +571,17 @@ public abstract class ServerSyncStage ex
 
   /**
    * We synced this engine!  Persist timestamps and advance the session.
    *
    * @param synchronizer the <code>Synchronizer</code> that succeeded.
    */
   @Override
   public void onSynchronized(Synchronizer synchronizer) {
-    stageCompleteTimestamp = System.currentTimeMillis();
+    stageCompleteTimestamp = SystemClock.elapsedRealtime();
     Logger.debug(LOG_TAG, "onSynchronized.");
 
     SynchronizerConfiguration newConfig = synchronizer.save();
     if (newConfig != null) {
       persistConfig(newConfig);
     } else {
       Logger.warn(LOG_TAG, "Didn't get configuration from synchronizer after success.");
     }
@@ -600,17 +601,17 @@ public abstract class ServerSyncStage ex
    * the next sync will include this sync's data), but do advance the session
    * (if we didn't get a Retry-After header).
    *
    * @param synchronizer the <code>Synchronizer</code> that failed.
    */
   @Override
   public void onSynchronizeFailed(Synchronizer synchronizer,
                                   Exception lastException, String reason) {
-    stageCompleteTimestamp = System.currentTimeMillis();
+    stageCompleteTimestamp = SystemClock.elapsedRealtime();
     Logger.warn(LOG_TAG, "Synchronize failed: " + reason, lastException);
 
     // This failure could be due to a 503 or a 401 and it could have headers.
     // Interrogate the headers but only abort the global session if Retry-After header is set.
     if (lastException instanceof HTTPFailureException) {
       SyncStorageResponse response = ((HTTPFailureException)lastException).response;
       if (response.retryAfterInSeconds() > 0) {
         session.handleHTTPError(response, reason); // Calls session.abort().