-
-
Notifications
You must be signed in to change notification settings - Fork 278
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
Extend instance state CPU data to include maximum possible CPU usage (ns) per second #1730
Comments
I'm not sure how you'd get a percentage value by knowing the current CPU count. The data we get from the kernel is the total CPU time since start of the instance, this doesn't account for any change in the number of CPUs available to the instance during its lifetime or changes in CPU availability on the host such as isolated CPUs or similar dedicated allocations to other processes on the system. So knowing that your container used 300s of CPU time, has been running for a week and is on a 64 core system would have your report 0.000775% of CPU usage. That doesn't seem terribly useful to me. I suspect what most folks are actually after is an instant CPU consumption in percentage but that we definitely don't have the data for. |
No, but doing
I’m not sure that invalidates my point.
It’s not, so I’m not suggesting exposing the CPU percentage, only CPU time and CPU count. The idea is to allow a WebUI (to be honest, I happen to have started developing one a few months ago) to show immediate (well, after at least 2 measurements) CPU usage in a meter bar, as you currently do on the branded UI with memory and disk, and as most other hypervisor UIs do. On a meter bar, 100% does not mean 100% CPU time, but 100% CPU time on all the CPUs, as 100% CPU time means one CPU being at 100% capacity.
Well, we do, if we have the CPU count. |
Okay, that makes sense. When using a client which can gather multiple data points, then you can calculate a CPU usage percentage for that time period. Adding a "count" field to the CPU state struct which reports the number of CPUs based on cpuset should be reasonably straightforward (minus the parsing of the cpuset value but we already have code for that). How do you want to handle Just returning the CPU count (4) would be quite incorrect as the container is only allowed to use 50% of one full CPU core worth of time, so should the CPU count be 0.5 then, do we need a separate field to handle the count of CPU threads as opposed to the amount of CPU time that can be used? Or should we return something like a total of CPU time in nanoseconds that can be used per second of real time? So you'd get:
|
Yeah, sorry if the original message was not clear :)
Oh that’s a tricky one…
I really like this solution
You meant Then it’ll be up to the UI to say “xx% out of yy equivalent CPUs” or stuff like that, or to find a better wording. |
Nope, I meant This expands to:
So basically so long as you have |
Oh right, I had misinterpreted the allowance policy (never used before) |
/state
endpoint
@bensmrs you want to take this one? |
Yeah I can do that. But I probably won’t look at it until we’ve finished our mega-PR :) |
For LXC, shall I take into account |
The priority is really just a scheduling priority when under load, so I don't think it would cause a change to the returned value in this case.
You should still be able to read the CPU set from the cgroup, even if no limit is applied. On cgroup2, you'd basically want to read We have the cgroup package that helps with that with:
Logic would then basically be:
|
Currently, only CPU time is reported in the
/state
API endpoint for instances. While the total CPU time can be interesting to some, I think most users are actually interested in a CPU usage in percents (which we can calculate easily from CPU time) relative to the CPU count (which we don’t have access to).The text was updated successfully, but these errors were encountered: