12
4
How can I get the true usage of a multicore hyperthreading enabled cpu?
For example lets consider a 2 core CPU, expressing 4 virtual cores.
A single threaded workload would now show up as 100% in top
, as one core of the virtual cores is completely used. The CPU and top
work as expected, like there would be 4 real cores.
With two threads however, the things get arkward: If all works well, they are balanced to the two real cores, so we got 200% usage: Two times 100% and two idle virtual cores, and are using all of the available CPU power. Seems ok to me.
However, if the two threads would run on a single real core, they would show up as using two times 100%, that makes 200% virtual core usage. But on the real side, that would be one core sharing its power on the two threads, which are then using only one half of the total CPU power.
So the usage numbers shown by top
can not be used to measure the total CPU workload.
I also wonder how hyperthreading balances two virtual on a real core. If two threads take a different amount of cycles, would the virtual cores 'adapt' so that both show a 100% load even if the real load differ?
1@Ramhound, so if I have a physical 4-core processor with 8 logical cores, and my load averages say 4.00, am I at 100% utilization or 50%? – Buttle Butkus – 2015-10-08T21:26:42.703
1You do understand the operator system is not aware of the difference between a hyperthreading virtual core and the physical core right? – Ramhound – 2013-06-28T10:15:27.367
It seems so, but it doesn't have to? The real vs. virtual core mapping is a simple one to two map. The problem is how to measure load on a virtual core that actually changes its available performance by getting scheduled with another one on the real core. But all data is avalable I think, the question is just where are the tools that get a proper result out of them? – dronus – 2013-07-19T00:14:59.210
1I just like to have a load measure where 100% would mean that every cycle of every real core is used. – dronus – 2013-07-19T00:17:15.373
It's not clear why you come to that conclusion – Ramhound – 2013-07-19T22:47:33.983
This is obviously a reason why the OS should be aware of virtual cores. So it has to find out and compute the physical core usage based on it. Otherwise the whole concept of measureing "usage" and "load" has no use to the user. If I run
top
, I usually have some question like "Is the system running at it's limit?" or "Would it be useful to divide the work into more processes?" etc. This questions can't be reliable answered by the currenttop
output. – dronus – 2013-07-25T12:45:51.390Its still not clear what your actual question is. If the operating ssytem is not aware the difference between physical cores and a virtual cores ( at least with regards to threads ) it can detect the amount of physical cores because thats something the CPU actually transmits. – Ramhound – 2013-07-25T12:57:54.067
My question is how to get the total usage of available cpu cycles. I think you're saying 'you can't get that value because the OS isn't capable of knowing it', but I am not aware why. The OS may know if hyperthreading happens by probing the behaviour or having some CPU driver defining if the current CPU model uses it or not. In worst case, the OS truely is incapable of handling this, I like to have a suggestion how to compute the value by myself using my knowledge of my current CPU hyperthreading capabilities. – dronus – 2013-08-24T20:10:57.627
1Simply spoken: How to tell at a given moment, if my CPU would be capable to do further work, without slowing down the currently ongoing work? – dronus – 2013-08-24T20:13:12.370