The hypervisor virtualizes cores by assigning time slots between the virtual processors. To perform the required emulation, certain instructions and operations require the hypervisor and virtualization stack to run. Moving a workload into a virtual machine increases the CPU usage, but this guide describes best practices for minimizing that overhead.
Virtual Machine Integration Services
The virtual machine Integration Services include enlightened drivers for the Hyper-V-specific I/O devices, which significantly reduces CPU overhead for I/O compared to emulated devices. You should install the latest version of the virtual machine Integration Services in every supported guest. The services decrease the CPU usage of the guests, from idle guests to heavily used guests, and improves the I/O throughput. This is the first step in tuning performance in a server running Hyper-V . For the list of supported guest operating systems, see the documentation that is provided with the Hyper-V installation.
The operating system kernels in Windows Server 2012, Windows Server 2008 R2, Windows Server 2008, Windows 8, Windows 7, and Windows Vista with SP1 feature enlightenments that optimize their operation for virtual machines. For best performance, we recommend that you use one of these Windows operating systems as a guest operating system.
The enlightenments present in Windows Server 2012, Windows Server 2008 R2, and Windows Server 2008 decrease the CPU overhead of the Windows operating system that is running in a virtual machine. The Integration services provide additional enlightenments for I/O. Depending on the server load, it can be appropriate to host a server application in a Windows Server guest for better performance.
Hyper-V in Windows Server 2012 supports a maximum of 64 virtual processors per virtual machine. Virtual machines that have loads that are not CPU intensive should be configured to use one virtual processor. This is because of the additional overhead that is associated with multiple virtual processors, such as additional synchronization costs in the guest operating system.
Increase the number of virtual processors if the virtual machine requires more than one CPU of processing under peak load. The documentation that is provided with the Hyper-V installation lists the supported guest operating systems. For more information, see see Hyper-V Overview in the Windows Server Technical Library.
Windows Server 2012 features enlightenments to the core operating system that improve scalability in multiprocessor virtual machines. Workloads can benefit from the scalability improvements in Windows Server 2012 if they run virtual machines with up to 64 virtual processors.
Minimizing the background activity in idle virtual machines releases CPU cycles that can be used elsewhere by other virtual machines or saved to reduce energy consumption. Windows guests typically use less than one percent of one CPU when they are idle. The following are several best practices for minimizing the background CPU usage of a virtual machine:
Install the latest version of the virtual machine Integration Services.
Remove the emulated network adapter through the virtual machine settings dialog box (use the Microsoft Hyper-V-specific adapter).
Keep the Windows guest on the sign-in screen when it is not being used.
Use Windows Server 2012, Windows Server 2008 R2, or Windows Server 2008 for the guest operating system.
Disable the screen saver.
Disable, throttle, or stagger periodic activity such as backup and defragmentation.
Review the scheduled tasks and services that are enabled by default.
Improve server applications to reduce periodic activity (such as timers).
Use the default Balanced power plan instead of the High Performance power plan.
The following are additional best practices for configuring a client version of Windows in a virtual machine to reduce the overall CPU usage:
Disable background services such as SuperFetch and Windows Search.
Disable scheduled tasks such as Scheduled Defrag.
Disable Aero glass and other user interface effects (through the System application in Control Panel).
Weights and Reserves
Hyper-V supports setting the weight of a virtual processor to grant it a larger or smaller share of CPU cycles than average and specifying the reserve of a virtual processor to make sure that it gets a minimal percentage of CPU cycles. The CPU that a virtual processor consumes can also be limited by specifying usage limits. System administrators can use these features to prioritize specific virtual machines, but we recommend the default values unless you have a compelling reason to alter them.
Weights and reserves prioritize or de-prioritize specific virtual machines if CPU resources are overcommitted. This ensures that those virtual machines receive a larger or smaller share of the CPU. Highly intensive loads can benefit from adding more virtual processors instead, especially when they are close to saturating an entire core.
On Non-Uniform Memory Access (NUMA) hardware, each virtual machine has a default NUMA node preference. Hyper-V uses this NUMA node preference when assigning physical memory to the virtual machine and when scheduling the virtual machine’s virtual processors. A virtual machine performs optimally when its virtual processors and memory are on the same NUMA node.
By default, the system assigns the virtual machine to its preferred NUMA node every time the virtual machine is run. An imbalance of NUMA node assignments might occur depending on the memory requirements of each virtual machine and the order in which each virtual machine is started. This can lead to a disproportionate number of virtual machines being assigned to a single NUMA node.
Use Perfmon to check the NUMA node preference setting for each running virtual machine by examining the \Hyper-V VM Vid Partition (*)\ NumaNodeIndex counter.
You can change NUMA node preference assignments by using the Hyper-V WMI API. To set the NUMA node preference for a virtual machine, set the NumaNodeListproperty of the Msvm_VirtualSystemSettingData class. For information about the WMI calls that are available for Hyper-V and for a blog post about NUMA node balancing, see Resources later in this guide.