mirror of
https://github.com/kopia/kopia.git
synced 2026-01-27 07:48:06 -05:00
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>
15 lines
569 B
Go
15 lines
569 B
Go
// Package clock provides indirection for accessing current wall clock time.
|
|
// this is suitable for timestamps and long-term time operations, not short-term time measurements.
|
|
package clock
|
|
|
|
import "time"
|
|
|
|
// discardMonotonicTime discards any monotonic time component of time,
|
|
// which behaves incorrectly when the computer goes to sleep and we want to measure durations
|
|
// between points in time.
|
|
//
|
|
// See https://go.googlesource.com/proposal/+/master/design/12914-monotonic.md
|
|
func discardMonotonicTime(t time.Time) time.Time {
|
|
return time.Unix(0, t.UnixNano())
|
|
}
|