You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Windows: spored counts hibernated time as compute (Go's monotonic clock includes it) #962
Found while fixing #945. Not reproduced live: this comes from reading the Go runtime source, not from a Windows instance.
On Linux, #945 measures compute on CLOCK_MONOTONIC, which stops while the instance is hibernated, so a hibernate-and-resume is no longer counted as compute. Windows works differently.
What happens on Windows. There is no compute clock file or durable checkpoint on Windows (sysComputeClockPath and sysComputeCheckpointPath return ""), so the #945 cross-process cases do not apply. The daemon counts computeSecondsBase + time.Since(startTime) in-process, through Go's monotonic clock reading. On Windows, Go's runtime.nanotime reads KUSER_SHARED_DATA.InterruptTime (runtime/sys_windows_amd64.s, nanotime1). That is the biased interrupt time, which keeps counting through sleep and hibernation. So after a hibernate-and-resume the daemon's own count includes the hibernated interval. That feeds:
spawn:compute-seconds, and from there spawn status on a stopped instance;
--cost-limit enforcement;
the status compute cost, on the checkpoint fallback.
On Linux the in-process count was already correct before #945, because Go's Linux monotonic clock is CLOCK_MONOTONIC. Windows has never had that.
Expected. Hibernated time is not compute. EC2 does not bill compute while an instance is hibernated, on Windows or Linux.
Possible fix. Implement sysKernelClocks in pkg/agent/sys_windows.go (added in #945) using:
QueryUnbiasedInterruptTime for the Monotonic reading. It excludes sleep and hibernation.
QueryInterruptTime, or the biased interrupt time, for Boottime.
Both are 100ns units since boot. The in-process count then uses the same path as Linux, and spored status gets HibernatedTime for free once a clock is published. Publishing one needs a boot-scoped id and location on Windows, which is a separate question (#896 and #928 chose not to).
This needs a Windows instance to verify that the unbiased interrupt time excludes an EC2 hibernation. That launch was out of scope for #945.
Activity
Exclude hibernated time from compute on Windows: measure it on the un…
Exclude hibernated time from compute on Windows: measure it on the un…
Exclude hibernated time from compute on Windows: measure it on the un…
Exclude hibernated time from compute on Windows: measure it on the un…
Exclude hibernated time from compute on Windows: measure it on the un…
Exclude hibernated time from compute on Windows: measure it on the un…
Exclude hibernated time from compute on Windows: measure it on the un…
Exclude hibernated time from compute on Windows: measure it on the un…
Load QueryInterruptTime from the realtime API set, not kernel32 (#962)
Exclude hibernated time from compute on Windows (#962) (#970)