Fixes logic for calculating percentage for cgroups.Stats.CpuStats.CpuUsage.PercentUsage
Previous logic divided a uint64 by a uint64 losing precision before multiplying by clock ticks and cpus This fix maintains precision before converting back to uint64 Docker-DCO-1.1-Signed-off-by: Nicholas Weaver <lynxbat@gmail.com> (github: lynxbat)
This commit is contained in:
parent
ef3c88435e
commit
8597998244
|
@ -73,7 +73,7 @@ func (s *CpuacctGroup) GetStats(path string, stats *cgroups.Stats) error {
|
|||
deltaUsage = lastUsage - startUsage
|
||||
)
|
||||
if deltaSystem > 0.0 {
|
||||
percentage = ((deltaProc / deltaSystem) * clockTicks) * cpuCount
|
||||
percentage = uint64(((float64(deltaProc) / float64(deltaSystem)) * float64(clockTicks)) * float64(cpuCount))
|
||||
}
|
||||
// NOTE: a percentage over 100% is valid for POSIX because that means the
|
||||
// processes is using multiple cores
|
||||
|
|
Loading…
Reference in New Issue