To improve the virtual machine performance, you can add, change, or configure CPU resources.

Enable CPU Hot Add

By default, you cannot add CPU resources to a virtual machine when the virtual machine is powered on. The CPU hot add option lets you add CPU resources to a running virtual machine.

The following conditions apply.

  • For best results, use virtual machines that are compatible with ESXi 5.0 or later.
  • Hot adding multicore virtual CPUs is supported only with virtual machines that are compatible with ESXi 5.0 or later.
  • If a virtual machine has 128 virtual CPUs or less, you cannot use hot adding to further increase the number of virtual CPUs to be over 128. To change the number of virtual CPUs beyond that limit, you must first power off the virtual machine. By contrast, if a virtual machine already has more than 128 virtual CPUs, you can use hot adding to further increase the number of virtual CPUs to up to 768.
  • Not all guest operating systems support CPU hot add. You can deactivate these settings if the guest operating system is not supported.
  • To use the CPU hot add feature with virtual machines that are compatible with ESXi 4.x and later, set the Number of cores per socket to 1.
  • Adding CPU resources to a running virtual machine with CPU hot add enabled disconnects and reconnects all USB passthrough devices that are connected to that virtual machine.
Note: If the ESXi host is of version 7.0 Update 2 and earlier, hot-adding virtual CPUs to a virtual machine with NVIDIA vGPU requires that the ESXi host have a free vGPU slot. Starting with vSphere 7.0 Update 3, the source host does not require to a have a free vGPU slot.

Prerequisites

  • Verify that the virtual machine is configured as follows.
    • Latest version of VMware Tools installed.
    • Guest operating system that supports CPU hot add.
    • Virtual machine compatibility is ESX/ESXi 4.x or later.
    • Virtual machine is powered off.
  • Required privileges: Virtual Machine.Configuration.Settings

Procedure

  1. Right-click a virtual machine in the inventory and select Edit Settings.
  2. On the Virtual Hardware tab, expand CPU, and select Enable CPU Hot Add.
  3. Click OK.

Results

You can now add CPUs even if the virtual machine is powered on.

Change the Number of Virtual CPUs

A virtual machine with ESXi 7.0 Update 1 and later compatibility can have up to 768 virtual CPUs. You can change the number of virtual CPUs while your virtual machine is powered off. If virtual CPU hot add is enabled, you can increase the number of virtual CPUs while the virtual machine is running.

Virtual CPU hot add is supported for virtual machines with multicore CPU support and ESXi 5.0 and later compatibility. When the virtual machine is powered on and CPU hot add is enabled, you can hot add virtual CPUs to the running virtual machine. You can add only multiples of the number of cores per socket.

If a virtual machine has 128 virtual CPUs or less, you cannot use hot adding to further increase the number of virtual CPUs. To change the number of virtual CPUs beyond that limit, you must first power off the virtual machine. By contrast, if a virtual machine already has more than 128 virtual CPUs, you can use hot adding to further increase the number of virtual CPUs to up to 768.

The maximum number of virtual CPU sockets that a virtual machine can have is 128. If you want to configure a virtual machine with more than 128 virtual CPUs, you must use multicore virtual CPUs.

Important: When you configure your virtual machine for multicore virtual CPU settings, you must ensure that your configuration complies with the requirements of the guest operating system EULA.

Prerequisites

  • If CPU hot add is not enabled, power off the virtual machine before adding virtual CPUs.
  • To hot add multicore CPUs, verify that the virtual machine is compatible with ESXi 5.0 and later.
  • Verify that you have the Virtual Machine.Configuration.Change CPU Count privilege.

Procedure

  1. Right-click a virtual machine in the inventory and select Edit Settings.
  2. On the Virtual Hardware tab, expand CPU.
  3. From the CPU drop-down menu, select the number of cores.
  4. From the Cores Per Socket drop-down menu, select the number of cores per socket and click OK.

Expose VMware Hardware Assisted Virtualization

You can expose full CPU virtualization to the guest operating system so that applications that require hardware virtualization can run on virtual machines without binary translation or paravirtualization.

Prerequisites

Note: VMware does not support running third-party hypervisors on ESXi with the exception of specifically defined and documented functionality. Currently, this is limited to Microsoft Hyper-V, strictly for VBS only and not for virtualizing multiple VMs.

For more information, see the VMware KB article at https://kb.vmware.com/s/article/2009916.

  • Verify that the virtual machine compatibility is ESXi 5.1 and later.
  • Intel Nehalem Generation (Xeon Core i7) or later processors or AMD Opteron Generation 3 (Greyhound) or later processors.
  • Verify that Intel VT-x or AMD-V is enabled in the BIOS so that hardware assisted virtualization is possible.
  • Required Privileges: Virtual machine.Change Configuration.Change Settings set on the vCenter Server system.

Procedure

  1. Right-click a virtual machine in the inventory and select Edit Settings.
  2. On the Virtual Hardware tab, expand CPU, and select Expose hardware assisted virtualization to the guest OS.
  3. Click OK.
    The Configure tab refreshes, and the Nested Hypervisor CPU option shows Enabled.

Activate Virtual CPU Performance Counters

You can use performance tuning tools in the guest operating system for software profiling. You can identify and improve processor performance problems. This capability is useful for software developers who optimize or debug software that runs in the virtual machine.

The following conditions apply:
  • If virtual CPU performance counters are enabled, you can migrate the virtual machine only to hosts that have compatible CPU performance counters.
  • If an ESXi host's BIOS uses a performance counter or if Fault Tolerance is enabled, some virtual performance counters might not be available for the virtual machine to use.
Note: If a virtual machine resides on an ESXi host in an EVC cluster, CPU counters are not supported for virtual machine creation or editing. You must deactivate CPU performance counters.
For a list of virtualized Model-Specific Registers (MSRs), see the VMware knowledge base article at http://kb.vmware.com/kb/2030221.

Prerequisites

  • Verify that the virtual machine compatibility is ESXi 5.1 and later.
  • Verify that the virtual machine is turned off.
  • Verify that Intel Nehalem Generation (Xeon Core i7) or later processors or AMD Opteron Generation 3 ("Greyhound") or later processors are installed.
  • Verify that Intel VT-x or AMD-V is enabled in the BIOS so that hardware-assisted virtualization is possible.
  • Required Privileges: Virtual machine.Change Configuration.Change Settings is set on the vCenter Server system.

Procedure

  1. Right-click a virtual machine in the inventory and select Edit Settings.
  2. On the Virtual Hardware tab, expand CPU and select the Enable virtualized CPU performance counters check-box.
  3. Click OK.

Configure Processor Scheduling Affinity

The Scheduling Affinity option gives you detailed control over how virtual machine CPUs are distributed across the host's physical cores. The option supports hyperthreading if hyperthreading is enabled. ESXi generally manages processor scheduling well, even when hyperthreading is enabled. These settings are useful only for fine-tuning critical virtual machines.

Using CPU affinity, you can assign a virtual machine to a specific processor. This assignment allows you to restrict the assignment of virtual machines to a specific available processor in multiprocessor systems.

This setting does not appear for virtual machines in a DRS cluster or when the host has only one processor core and no hyperthreading.

For potential issues with CPU affinity, see the vSphere Resource Management documentation.

Prerequisites

  • Verify that the virtual machine is turned off.
  • Verify that the virtual machine does not reside in a DRS cluster.
  • Verify that the host has more than one physical processor core.
  • Privileges: Virtual machine.Change Configuration.Change resource

Procedure

  1. Right-click a virtual machine in the inventory and select Edit Settings.
  2. On the Virtual Hardware tab, expand CPU, and enter a comma-separated list of hyphenated processor ranges in the Scheduling Affinity text box.
    For example, "0,4-7" would indicate affinity with CPUs 0,4,5,6, and 7. Selecting all processors is identical to selecting no affinity. You must provide at least as many processor affinities as you have virtual CPUs.
  3. Click OK.

Change CPU/MMU Virtualization Settings

ESXi can determine whether a virtual machine needs hardware support for virtualization. ESXi makes this determination based on the processor type and the virtual machine. Overriding the automatic selection can provide better performance for some use cases.

Important: Modern x86 processors can fully support virtualized workloads without software assistance. So, the CPU/MMU Virtualization setting has been deprecated in ESXi 6.7 and later. The CPU/MMU Virtualization setting is available only for virtual machines with ESXi 6.5 and later compatibility.

You can use software MMU when your virtual machine runs heavy workloads, such as Translation Lookaside Buffers (TLBs) intensive workloads that have significant impact on the overall system performance. However, software MMU has a higher overhead memory requirement than hardware MMU. So, to support software MMU, the maximum overhead supported for virtual machine limit in the VMkernel must be increased.

Procedure

  1. Right-click a virtual machine in the inventory and select Edit Settings.
  2. On the Virtual Hardware tab, expand CPU, and select an instruction set from the CPU/MMU Virtualization drop-down menu.
    Note: To take advantage of all features that virtual hardware version 13 provides, use the default hardware MMU setting.

    You cannot change the CPU/MMU Virtualization setting of virtual machines with ESXi 6.7 and later compatibility.

  3. Click OK.