The root cause of the high system_p
value is that the cpu.system
value decreases by 1.
sys_delta = cpu_2.system - cpu_1.system = 20409 - 20410 = -1
Since Topbeat was not expecting a negative delta it uses an uint64
variable type to store the sys_delta value. Since this is an unsigned variable, the value becomes 18446744073709551615
instead of -1
. This is why the system_p
value is really large.
If I change the variable type used to store the "sys_delta
" value then the resulting system_p
value becomes -0.06
. It doesn't make sense, but at least it's representative of the values used in the calculation.
I pasted the relevant code and your values into the Golang playground for demonstration.
So what's causing the cpu.system
value to decrease? It's either Windows or the elastic/gosigar library. I suspect it's the library. There is some floating point arithmetic being used to calculate the values. Instead of using floating point I think it should use this method.
Sorry for the long post. Would you be able to test a development build if I make a change?