Skip to main content

Disable Hyper-Threading on an Azure VM

· 3 min read

In some (probably very rare) cases you will need to disable Hyper-Threading on a virtual machine in Azure. This post explains how to achieve this.

Why would I want to disable Hyper-Threading?

Firstly, Hyper-Threading is a good thing. I won't go into detail about what Hyper-Threading is in this post. I'll let Wikipedia explain that. In short, it allows machines to present 2 logical processors, per physical core. This can provide performance improvements to most workloads.

In some (again very rare) cases you may need strong reliability of a CPU bound workload, to guarantee consistency. This could be pertinent to things like performance testing that require strict response times from the CPU. Hyper-Threading can give very marginal differences here; but again, I won't go into the details of how here.

It's also worth pointing out there have been some very well-known vulnerabilities in CPUs with Hyper-Threading and the initial recommendations were to disable Hyper-Threading entirely.

Hackers

How to disable Hyper-Threading

Firstly, you should check to see if your VM series is capable of Hyper-Threading. The vCPU:Core ratio is published here. This should give you an indication if the CPU used for the VM series has this capability.

Azure do have some basic guidance around disabling Hyper-Threading. It refers to creating a support ticket in the Azure portal as the recommended way to initiate the request.

To do this you should select the following options on the Support Request:

  • Summary: "Disable Hyper-Threading"
  • Issue Type: Technical
  • Subscription: [YOUR SUBSCRIPTION NAME/ID]
  • Service Type: My Services, Virtual Machine running Windows
  • Resource: [VM Name]
  • Problem Type: Azure Features
  • Problem subtype: Hyper-Threading (enable or disable)

Unfortunately it is not an automated process, so expect a human response within your typical support SLA.

Once you have a reply, the typical response is that Microsoft will add your subscription to turn on the functionality to enable/disable Hyper-Threading through tags on the VM resource.

The tag you will need to configure is called platformsettings.host_environment.disablehyperthreading. Setting this tag with the value of true will immediately disable Hyper-Threading on the VM. If the tag is ommitted or set to anything other than true, Hyper-Threading will be left enabled.

I'm intrigued to know what other tags there are to influence the environment!

On windows, you can confirm if the number of logical processors matches the number of cores with the command wmic cpu get NumberOfCores,NumberOfLogicalProcessors

Re-Enabling Hyper-Threading

If you wish to re-enable Hyper-Threading, all you need to do is remove the tag and restart the machine. This should return the Hyper-Threading configuration on the VM as it once was.

Simarily if you wish to disable the ability to set this tag, it requires a further support request with Microsoft following the same route as above

Summary

In most cases, Hyper-Threading is best left untouched, but hopefully this shows how to switch this off if needed!

That's all