Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows getloadavg moving averages are incorrect #1552

Closed
bolterr opened this issue Jul 19, 2019 · 3 comments
Closed

Windows getloadavg moving averages are incorrect #1552

bolterr opened this issue Jul 19, 2019 · 3 comments
Assignees

Comments

@bolterr
Copy link

bolterr commented Jul 19, 2019

Platform

  • Windows
  • 5.6.3

Bug description
Thanks for implementing getloadavg for windows in psutil/psutil/arch/windows/wmi.c

I think that there was a slipup with the factors:

#define LOADAVG_FACTOR_1F 0.9200444146293232478931553241
#define LOADAVG_FACTOR_5F 0.6592406302004437462547604110
#define LOADAVG_FACTOR_15F 0.2865047968601901003248854266

LOADAVG_FACTOR_1F is good but I think LOADAVG_FACTOR_5F and LOADAVG_FACTOR_15F should be as follows:

#define LOADAVG_FACTOR_5F 0.9834714538216174894737477501 // 1/exp(5/300)
#define LOADAVG_FACTOR_15F 0.9944598480048967508795473395 // 1/exp(5/900)

This better matches linux/sched/loadavg.h:

LOADAVG_FACTOR_1F = 1884/2048= 0.92...
LOADAVG_FACTOR_5F = 2014/2048= 0.98...
LOADAVG_FACTOR_14F = 2037/2048= 0.99...

Sorry, I would post a pr if I could.

@giampaolo
Copy link
Owner

@ammaraskar do you agree with the analysis?

@ammaraskar
Copy link
Contributor

Aah yeah, this seems to be right. The calculations and wolfram links are provided here: #1484 (comment)

were wrong due to the brackets, it should have been 1/exp(5 / (60*5)) but instead I used 1/exp(5 / 60*5) which gives a completely different result.

Sorry about that, I'll make a PR to fix it.

@giampaolo
Copy link
Owner

Thanks man.

ammaraskar added a commit to ammaraskar/sysinfo that referenced this issue Jul 2, 2020
There was an error in the parenthesis during the calculation of this constant, fixing this in the downstream projects where it got propagated to. See
giampaolo/psutil#1552
giampaolo/psutil#1583
ammaraskar added a commit to ammaraskar/SWARM that referenced this issue Jul 2, 2020
There was an error in the parenthesis during the calculation of this constant, fixing this in the downstream projects where it got propagated to. See
giampaolo/psutil#1552
giampaolo/psutil#1583
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants