Disable Hyperthreading on Azure Windows VM
Hyperthreading is an innovation found on some Intel and AMD chips to improve performing multiple tasks by running tasks in parallel fashion on the computer processor.
Because multi-tasking is fairly common in most computational workloads, hyper-threading is usually quite useful and allows your processors to handle more jobs concurrently rather than queuing them up and processing serially. This reduces idle CPU time and works particularly well for video editing, rendering operations, and multi-user environments.
In Azure, D-series (v3, v4), E-series, some of F-series, etc. compute sizes use the technology of Hyperthreading.
Overview of the Azure Compute Unit provides detailed description of all VM Sizes and hyperthreading options available.
How to check if the VM has hyperthreading enabled?
With Hyper-threading enabled the Operating System will address each physical or virtual CPU core as two logical cores or “threads”. For example if a particular Virtual Machine has 2 virtual cores assigned this will be represented as 4 logical cores — a 2:1 ratio of logical cores to virtual cores.
Access the windows command line from within the VM and type wmic to enter the interactive wmic interface. Then, you can type:
CPU Get NumberOfCores,NumberOfLogicalProcessors /Format:List
This will allow you to view the amount of physical and logical processors. If the number of logical processors is greater than physical processors (cores), then hyperthreading is enabled.
How to disable Hyperthreading on Azure VM running Windows?
As the hyper-threading is enabled by default on the select Azure VM Sizes, below are the three ways if you want to disable hyper-threading on a VM running Windows:
Azure Portal
The following tag can be added in the portal and set as true:
platformsettings.host_environment.disablehyperthreading
Azure CLI
az resource tag — ids /subscriptions/{SubID}/resourceGroups/{ResourceGroup}/providers/Microsoft.Compute/virtualMachines/{VM}— tags platformsettings.host_environment.disablehyperthreading=true
Note: Using “az resource tag” for VM/VMSS updates behaves like a “put” and overrides the resource’s existing tags with the specified tags. This means that if the resource had a tag that isn’t specified in — tags, it is overwritten.
Powershell
For VMs: use the –Tag flag when using New-AzureRmVm (alternatively, use the –Tags flag when creating the VM config with New-AzureRmVmConfig)
Set-AzureRmResource -ResourceGroupName <RGName> -Name <VMName> -ResourceType “Microsoft.Compute/VirtualMachines” -Tag @{“platformsettings.host_environment.disablehyperthreading”=”true”}
Next Steps?
Once the Tag is place, then the specific VM in Azure needs to be redeployed.
Go to the VM’s left blade > Redeploy + reapply > Redeploy.
Validate if hyperthreading has been disabled:
Access the windows command line from within the VM and type wmic to enter the interactive wmic interface. Then, you can type:
CPU Get NumberOfCores,NumberOfLogicalProcessors /Format:List
If the number of logical processors is equal to physical processors (cores), then hyperthreading is disabled.
How to re-enable Hyperthreading on Azure VM running Windows?
To re-enable Hyperthreading, remove the “platformsettings.host_environment.disablehyperthreading” tag and stop (deallocate) and start the VM from Azure. A Guest OS reboot is not sufficient.
Note: If this does not work for your VM, it might be possible that your ACU is locked from Microsoft’s backend and a support request needs to be raised. Once MS has unlocked your ACU, above steps can be followed to disable and re-enable the hyperthreading on Azure VM running Windows.
In case of any questions or concerns, find me at abhibothera.github.io.
About me:
Senior Cloud Engineer | 7x Microsoft Azure Certified | Solutions Architect | Azure DevOps | AVD | Security | Former Research Scholar at Georgia Tech.