Hello Chaps,
Does anyone know a way of disabling CPU hyperthreading via PowerCLI?
I can report whether it's enabled or not with this:
Get-Host | Select-Object Name,HyperthreadingActive
But now I need to disable it...
Thanks,
Dan
Hello, dtracey-
It looks like you can enable/disable hyperthreading on the host using the HostCpuSchedulerSystem, which is part of the HostConfigManager for the host. So, for one host, it would be something like:
## host upon which to act
$strMyHostName = "myhost.domain.com"
## get the View object for the HostCpuSchedulerSystem
$viewHostCPUSchedulerSystem = Get-View (Get-View -ViewType HostSystem -Property ConfigManager.CpuScheduler -Filter @{"Name" = $strMyHostName}).ConfigManager.CpuScheduler
## disable hyperthreading
$viewHostCPUSchedulerSystem.DisableHyperThreading()
You could quickly adjust this to do all desired hosts, as you see fit. Note, if the method succeeds, this tells the system to not "treat hyperthreads as schedulable resources the next time the CPU scheduler starts", per the docs.
Hello, dtracey-
It looks like you can enable/disable hyperthreading on the host using the HostCpuSchedulerSystem, which is part of the HostConfigManager for the host. So, for one host, it would be something like:
## host upon which to act
$strMyHostName = "myhost.domain.com"
## get the View object for the HostCpuSchedulerSystem
$viewHostCPUSchedulerSystem = Get-View (Get-View -ViewType HostSystem -Property ConfigManager.CpuScheduler -Filter @{"Name" = $strMyHostName}).ConfigManager.CpuScheduler
## disable hyperthreading
$viewHostCPUSchedulerSystem.DisableHyperThreading()
You could quickly adjust this to do all desired hosts, as you see fit. Note, if the method succeeds, this tells the system to not "treat hyperthreads as schedulable resources the next time the CPU scheduler starts", per the docs.
Hi Matt,
Ive played around with your script, but can't seem to get it to work. It appears that the DisableHyperThreading method doesnt exist.
Did you put that together from the vSphere 5 API documentation? As if so, I'm working with ESXi 4.1 hosts.
Did the script work for you?
Thanks for your help.
Dan
The DisableHyperThreading method is available in vSphere 4.1.
And the call works, provided you have CPUs that support HT of course.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello, Dan-
Hmm. Yes, as LucD pointed out, the method is available in vSphere 4.1 (just need CPUs that support hyperthreading). Yes, the host CpuSchedulerSystem I was using did have that method available.
What error(s) do you get, and at what point?
To be sure that the object that $viewHostCPUSchedulerSystem object has the DisableHyperThreading() method, you can use the Get-Member cmdlet. It should return something like:
PS C:\> $viewHostCPUSchedulerSystem | Get-Member
TypeName: VMware.Vim.HostCpuSchedulerSystem
Name MemberType Definition
---- ---------- ----------
DisableHyperThreading Method System.Void DisableHyperThreading()
EnableHyperThreading Method System.Void EnableHyperThreading()
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()....
What does this return for you?
Hi Matt,
I did actually manage to get this to work.
I think the reason it was failing initially is that when I connected to the host, i was using connect-viserver to the IP address and not to the hostname.
It seems to be happy now that i'm connecting using the hostname, i assume because the value for $vmhost is the fqdn rather than the IP...
I'm just going to have to try and work out how to ignore this command if hyperthreading is already disabled, but that's another day!
Thanks for your help.
Dan
Dan,
Is there any specific reason to turn HT off ?
I thought that by enabling HT you can perform multitasking more.
There is a nice collection of considerations in the post Hyper-threading on VMware vSphere
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Albert,
Its a mix of business constraints (legacy concepts of security and physical CPU sharing), and technical constraints. The (non Windows) OSes and apps that we run have been benchmarked and perform worse on HT CPUs.
It's a weird world!
Dan