Hyper-V: Clocks lie… which performance counters can you trust?


Many people have asked me how to do performance analysis using Hyper-V.  The first thing I always tell them is clocks lie.  Lets dig into this a little bit.


First some basic concepts.  There are two types of partitions that the Hypervisor manages.  The root partition which is special (manages physical devices, child partitions, … all except CPU and physical memory access which is the Hypervisors job) and the child partitions.  The child partitions are where the “Guest” virtual machines run.  The root partition has the “Root OS” or sometimes called “Host OS” (not technically correct in Hypervisor architectures).


Neither the Root nor the Guests VM’s control the PM Timer, APIC, … which means their concept of time in virtualized.  Something else to be aware of is both the Root and Guest virtual processors share the physical processors in a Round Robin like fashion.


Now let’s take a very important Windows Performance Counter – % Processor Time.  This performance counters details the total amount of CPU being used by a process, … (aka the CPU is not idling waiting for work).  There are other % Processor Time counters for that detail process time on a CPU like Internet Explorer running.


Now for the lie. Check the picture below.  On the guest I am running a CPU spinner program to make it 100% busy.  You can see perfmon running in the guest shows 100% utilization and the root shows ~85% utilization using the Hyper-V Hypervisor Guest Run Time counters.


clockslie


So which is correct?  Actually they both are.  The guest is using 100% of the CPU it has been given by the Hypervisor and each time the guest it running the CPU is busy running the spinner code.  Thus the guest is using 100% or a Virtual CPU.


The Hyper-V Hypervisor Logical Processor counters are showing Logical (aka Physical) Processor utilization.  This is what you are used to % Processor Time actually showing.


So if you are doing performance analysis and using performance counters be aware the counters in the Guest Virtual Machine “lie” so to speak.  What you need to use are the Hyper-V Hypervisor Performance Counters in the Root to get Physical Processor usage.


 


 

Comments (8)

  1. Mihir Patel says:

    Hi Tony,

    Is MS planning to publish more details about Hyper-V perfmon counters?  And how to compare virtual performance counters vs. native/parent/root performance counters.

    Thanks,

    Mihir

  2. This is one of the most important counter set in all of Hyper-V. It is also the only counter set that

  3. The “Hyper-V Hypervisor Virtual Processor” and “Hyper-V Hypervisor Root Virtual Processor” counter sets

  4. Abhaye says:

    Major concern in this regards, whether both 32/64 bit perfmon application shows these counter sets of Hyper-V

    Hyper-V Hypervisor Virtual Processor

    Hyper-V Hypervisor Root Virtual Processor

    Location of perfmon application for both the environment

    C:WindowsSystem32 perfmon.exe

    C:WindowsSysWOW64 perfmon.exe

     [Tony’s Reply]  Not sure I understand the question.  WS08 Hyper-V host is always 64bit.  The guests can be 32/64 bit.  The perfcounters in the root report on all guests.

  5. This is one of the most important counter set in all of Hyper-V. It is also one of the few counter sets

  6. Hyper-V Performance FAQ Anthony F Voellm (aka Tony) 6/19/2008 http://blogs.msdn.com/tvoellm Q: What is

  7. Now that Hyper-V has been in the market for over 9 months a common question that has come my way is “what

  8. clocks says:

    It's nice post! Thanks for this nice post and i like to know about clocks. I have little collection of clocks and i will try to upload that here.Thanks for this.