Bladeren bron

Exponential backoff for rapid follow up syncs. #2355

Christian Kamm 11 jaren geleden
bovenliggende
commit
fa4e6d8261
2 gewijzigde bestanden met toevoegingen van 13 en 1 verwijderingen
  1. 1 0
      src/gui/folder.h
  2. 12 1
      src/gui/folderman.cpp

+ 1 - 0
src/gui/folder.h

@@ -134,6 +134,7 @@ public:
      RequestEtagJob *etagJob() { return _requestEtagJob; }
      qint64 msecSinceLastSync() const { return _timeSinceLastSyncDone.elapsed(); }
      qint64 msecLastSyncDuration() const { return _lastSyncDuration; }
+     int consecutiveFollowUpSyncs() const { return _consecutiveFollowUpSyncs; }
 
 signals:
     void syncStateChange();

+ 12 - 1
src/gui/folderman.cpp

@@ -559,11 +559,22 @@ void FolderMan::startScheduledSyncSoon(qint64 msMinimumDelay)
         msDelay = qMax(msDelay, pause);
     }
 
+    // Punish consecutive follow-up syncs with longer delays.
+    if (Folder* nextFolder = folder(_scheduleQueue.head())) {
+        int followUps = nextFolder->consecutiveFollowUpSyncs();
+        if (followUps >= 2) {
+            // This is okay due to the 1min maximum delay limit below.
+            msDelay *= qPow(followUps, 2);
+        }
+    }
+
     // A minimum of delay here is essential as the sync will not upload
     // files that were changed too recently.
     msDelay = qMax(msDelay, msBetweenRequestAndSync);
 
-    // Delays beyond one minute seem too big.
+    // Delays beyond one minute seem too big, particularly since there
+    // could be things later in the queue that shouldn't be punished by a
+    // long delay!
     msDelay = qMin(msDelay, 60*1000ll);
 
     msDelay = qMax(1ll, msDelay - msSinceLastSync);