mirror of
https://github.com/kopia/kopia.git
synced 2026-10-23 22:58:42 -04:00
clock: discard monotonic clock component in clock.Now() (#1437)
The dual time measurement is described in https://go.googlesource.com/proposal/+/master/design/12914-monotonic.md The fix is to discard hidden monotonic time component of time.Time by converting to unix time and back. Reviewed usage of clock.Now() and replaced with timetrack.StartTimer() when measuring time. The problem in #1402 was that passage of time was measured using the monotonic time and not wall clock time. When the computer goes to sleep, monotonic time is still monotonic while wall clock time makes a leap when the computer wakes up. This is the behavior that epoch manager (and most other compontents in Kopia) rely upon. Fixes #1402 Co-authored-by: Julio Lopez <julio+gh@kasten.io>
This commit is contained in:
1 parent
c8c433fb60
commit
0d0f48a7ee
29 files changed
+123
-89
No files matched your search
@@ -48,13 +48,13 @@ func (c *logSelectionCriteria) filterLogSessions(allSessions []*logSessionInfo)
|
||||
|
||||
if c.youngerThan > 0 {
|
||||
allSessions = filterLogSessions(allSessions, func(ls *logSessionInfo) bool {
|
||||
return clock.Since(ls.startTime) < c.youngerThan
|
||||
return clock.Now().Sub(ls.startTime) < c.youngerThan
|
||||
})
|
||||
}
|
||||
|
||||
if c.olderThan > 0 {
|
||||
allSessions = filterLogSessions(allSessions, func(ls *logSessionInfo) bool {
|
||||
return clock.Since(ls.startTime) > c.olderThan
|
||||
return clock.Now().Sub(ls.startTime) > c.olderThan
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ func (c *commandMaintenanceInfo) displayCycleInfo(cp *maintenance.CycleParams, t
|
||||
c.out.printStdout(" interval: %v\n", cp.Interval)
|
||||
|
||||
if rep.Time().Before(t) {
|
||||
c.out.printStdout(" next run: %v (in %v)\n", formatTimestamp(t), clock.Until(t).Truncate(time.Second))
|
||||
c.out.printStdout(" next run: %v (in %v)\n", formatTimestamp(t), t.Sub(clock.Now()).Truncate(time.Second))
|
||||
} else {
|
||||
c.out.printStdout(" next run: now\n")
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user