Menu Close

Windows Server 2019 Hyper-V might only use half the available CPU’s?

I ran into this recently when migrating to a new lab Hyper-V server running Windows Server 2019.

I noticed after the migration of my VM’s from a Hyper-V 2016 to 2019 server, only half of the CPU’s were being used by my VM’s:

image

I hit up a friend who knows Hyper-V better than anyone I know – John Savill – and he pointed me in the direction of Hyper Threading as the likely source… which finally led me to this:

https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/manage/about-hyper-v-scheduler-type-selection

In Windows Server 2019, Hyper-V now defaults to a more secure “core scheduler” where previous versions used “classic scheduler” for CPU scheduling and isolation.  What this means, is that when you migrate a VM over to Hyper-V on WS2019, you need to update the VM configuration and change some settings, or it will only use a single hardware thread per core, exhibiting the behavior you see above.

In Hyper-V on WS2016, the default setting for number of Hardware Threads per Core is “1”.  What we want is to set this to “0” which will inherit the Host’s default configuration for this.

Here are the changes I made:

#Get your Host supported VM guest configuration versions Get-VMHostSupportedVersion #Get your VM guest configuration versions Get-VM | FT Name, Version #Update all VMs configuration versions Get-VM | Update-VMVersion #Get the VM thread count per core setting Get-VM | Get-VMProcessor | FT VMName,HwThreadCountPerCore #Set the VM thread count per core setting Get-VM | Set-VMProcessor -HwThreadCountPerCore 0

Now when I start up and examine at my VM’s on the host task manager, I am making full use of all available VM’s:

image

Note – this only impacts migrated VM’s.  When a VM is created on Windows Server 2019 Hyper-V, this is not an issue as the VM’s inherits the default setting of the Host.

10 Comments

  1. Stewart Myles

    Thanks this fixed it for us, Have you notice a performance decrease with the move to the core scheduler, we are seeing a noticeable decrease here same hardware just the OS changing to 2019?

    • Kevin Holman

      Interesting. No I didn’t notice any performance issues. What kind of perf issues and how are you measuring it?

  2. bob

    “Note – this only impacts migrated VM’s. When a VM is created on Windows Server 2019 Hyper-V, this is not an issue as the VM’s inherits the default setting of the Host.”

    Not quite true in terms of performance. Read this thread
    https://community.spiceworks.com/topic/2329272-hyperv-2019-vms-2x-slower-than-hv-2012-host-vms

    Making brand NEW VMs using 2019 will be 1/2 the speed of VMs you make if you force the VM to use the old classic scheduler. So in real word testing there is a still a performance loss.

  3. Ruben de Boer

    We did notice performance improvement. 15% more slack on the CPU’s
    Other thing from moving 2012 > 2019 Teamswitch. We noticed default teamswitch has 1/2 gig throughput. after trowing them away en rebuild them troughput = 3>5 Gig

  4. John

    I did a fresh and clean install of W2K19 on a host (Intel Xeom Silver 4210R) along with 4 virtual machines.
    Task Manager shows only every second core being busy.
    All VMs have the setting named above:

    VMName HwThreadCountPerCore
    —— ——————–
    VM01 0
    VM02 0
    VM03 0
    VM04 0

    I set HwThreadCountPerCore to 2 and it seems like all the “second cores” have to do something now.

    However I am not sure if doing this is a good idea. I will hardly be able to measure performance, I guess a W2K19 VM does not like e.g. PRIME95, does it?

  5. Pingback:Hyper-V: die ideale Anzahl vCPUs - nexcon ag

  6. Jan Janßen

    We had an issue with Server 2022 and amd CPU.
    When these settings not set from youre article and one Host have 30 VMs vmms Crash at Livemigration and destination Host no longer usable.

    Do you know about this issue with amd cpu‘s ?

Leave a Reply

Your email address will not be published.