Skip to content

Commit

Permalink
Adaptive sync draft
Browse files Browse the repository at this point in the history
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
  • Loading branch information
serathius committed Nov 29, 2024
1 parent 8f91eb1 commit ca33068
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions server/storage/mvcc/watchable_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,24 +220,8 @@ func (s *watchableStore) syncWatchersLoop() {
defer delayTicker.Stop()

for {
s.mu.RLock()
st := time.Now()
lastUnsyncedWatchers := s.unsynced.size()
s.mu.RUnlock()

unsyncedWatchers := 0
if lastUnsyncedWatchers > 0 {
unsyncedWatchers = s.syncWatchers()
}
syncDuration := time.Since(st)

s.syncWatchers()
delayTicker.Reset(waitDuration)
// more work pending?
if unsyncedWatchers != 0 && lastUnsyncedWatchers > unsyncedWatchers {
// be fair to other store operations by yielding time taken
delayTicker.Reset(syncDuration)
}

select {
case <-delayTicker.C:
case <-s.stopc:
Expand Down

0 comments on commit ca33068

Please sign in to comment.