Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm wondering about how Task Manager calculates CPU utilization in a virtualized environment. I can think of two ways:

  1. Count the number of cycles used and divide by the number of cycles available, OR

  2. Count the number of cycles used and divide by number of cycles that should have been available in the amount of elapsed time.

In a non-virtualized environment, these would lead to the same answer, but in a heavily utilized virtual environment, I could see how they would be different. (And I have a sneaking suspicion that Task Manager is using the second method, which means that I'm not getting a true picture of my CPU utilization.)

share|improve this question
3  
On the guests or on the host? –  EEAA Jul 23 '13 at 2:30
    
Yes. Guest or host. Guest - he has no clue how many cycles should have been there. Only how many he had. 100% (in the client) is thus relative to available time (assigned from the host). –  TomTom Jul 23 '13 at 12:05

1 Answer 1

Neither, actually. Task manager asks the kernel for these statistics. The kernel calculates idle time by measuring the time between when the CPU goes idle and when it has work to do again. CPU utilization is 100% minus the idle percentage.

In a VM, some CPU time disappears as the virtual processor is unscheduled for one reason or another. (Perhaps it caused a "VM exit" by touching emulated hardware, perhaps there was another VM that needed CPU time, etc.) When time disappears like that, it doesn't look like idle time to the VM, it looks like busy time.

So, in summary, Task Manager will tend to show the amount of CPU time used by the VM compared to the total share of time the hypervisor granted the VM. This is more or less, but no quite, #1 in your question.

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.