Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
1  
You do understand the operator system is not aware of the difference between a hyperthreading virtual core and the physical core right? – Ramhound Jun 28 '13 at 10:15
    
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 Jul 19 '13 at 0:14
    
I just like to have a load measure where 100% would mean that every cycle of every real core is used. – dronus Jul 19 '13 at 0:17
    
It's not clear why you come to that conclusion – Ramhound Jul 19 '13 at 22:47
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 Oct 8 '15 at 21:26

Core utilization is very different than the load on the system. Core utilization is only showing how much the core is calculating something or waiting for instructions. It can be 100% which correspons to any given time the cpu is calculationg someting.
But load is a different thing, load is a generally measured to determine if any process has to wait for any resource or not. If processes not waiting any resources you will see a very performant system. But sometimes you will see slow systems but low CPU utilization. Thay generally means some processes is waiting a resource and not releasing the cpu. At this kind of scenario you will not see high cpu utilization but the system may be well over its capacity. In a linux system Load avarage is a calculated value to measure the overall performance of a system. Value of the load avarage should be compared to the paralell computing resources, cores to be spesific. So if a system with 4 physical cores has a load avarage of 4 or more we can safely say that some processes will wait for a resource. It is not important if the cpu util is 100 or 10 percent. Load average can be as high as 200 or 300, in this cases system will be barely responsive. In a normal operating condition server load average should not exceed the number of cores for long duration. Short spikes are not important in my opinion. 3 numbers which you will see in a w output is load av. for 1/3/15 minutes.

share|improve this answer

Martin Tegtmeier at Oracle has written an interesting blog-post about this last year: https://blogs.oracle.com/partnertech/en/entry/cpu_utilization_of_multi_threaded

The short answer; Hyperthreading really messes with top's ability to report overall cpu-utilisation / cpu-idle percentages.

In the worst case, a 2-core 4-virtual-core CPU running 2 threads at 100%-utilisation-per-core, could nearly saturate the cpu. (Depending on execution port usage; only threads that use entirely different computing resources on the cpu could still run without affecting the performance on the current thread.) However, top will still report 50% idle in this case.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.