As promised at Teched Europe 2014, I am sharing each of the PowerShell scripts that I used to drive my feature demos in my session. The first of these scripts focuses on non-uniform memory access, or NUMA.
All of my demo scripts work in this kind of fashion:
- Clean up the lab
- Create demo environment variables for hosts, clusters, machines
- Write-Host “some cmdlet and parameters”
- Do the cmdlet and some parameters
- Optionally display the results
- Do more stuff
- Clean up the lab.
Most of the code in these scripts is fluff, purely for display and lab prep/reset.
In this script I:
- Clean up the lab, ensure the VM (spans NUMA nodes cos of vCPU count) is just the way I want it.
- Get the NUMA config of the host.
- Get the NUMA config of the VM.
- Show that the VM is not NUMA aligned.
- Retrieve the VM’s advanced NUMA configuration.
- Shutdown the VM, set it to use static memory, and restart it.
- Query the VMs NUMA alignment, and see that it is aligned now, but we have use static memory.
- Reset the lab back to the start.
CLS
$DemoVM1="NUMA"
#Reset the demo
Stop-VM $DemoVM1 -Force | Out-Null
Set-VMMemory $DemoVM1 -DynamicMemoryEnabled:$true -StartupBytes 512MB -MaximumBytes 8GB -MinimumBytes 256MB
Start-VM $DemoVM1 | Out-Null
#Start the demo
Read-Host "Start the demo"
Write-Host "`nGet-VMHostNumaNode"
Get-VMHostNumaNode
Write-Host "`nThe host has 2 NUMA nodes. Large VMs should also have 2 NUMA nodes for best performance" -foregroundcolor red -backgroundcolor yellow
Read-Host "`nCheck the NUMA and Dynamic Memory configuration of the VM $DemoVM1"
Write-Host "`nGet-VM $DemoVM1 | Select Name, ProcessorCount, MemoryMaximum, DynamicMemoryEnabled, NumaAligned, NumaNodesCount, NumaSocketCount"
Get-VM $DemoVM1 | Select Name, ProcessorCount, MemoryMaximum, DynamicMemoryEnabled, NumaAligned, NumaNodesCount, NumaSocketCount | Out-Host
Write-Host "`nGuest NUMA isn’t alligned and the 24 vCPU virtual machine has only 1 NUMA node" -foregroundcolor red -backgroundcolor yellow
Read-Host "`nGet the advanced NUMA configuration of the VM $DemoVM1"
Write-Host "`nGet-VMProcessor $DemoVM1 | Select Count, MaximumCountPerNumaNode, MaximumCountPerNumaSocket`n"
Get-VMProcessor $DemoVM1 | Select Count, MaximumCountPerNumaNode, MaximumCountPerNumaSocket
Write-Host "`nGet-VMMemory $DemoVM1 | Select MaximumPerNumaNode`n"
Get-VMMemory $DemoVM1 | Select MaximumPerNumaNode
Write-Host "`nThis is the NUMA node configuration that Hyper-V can present to the VM via Guest-Aware NUMA" -foregroundcolor red -backgroundcolor yellow
Read-Host "`nDisable Dynamic Memory for the VM $DemoVM1 & restart it"
Stop-VM $DemoVM1 -Force
Write-Host "`nSet-VMMemory $DemoVM1 -DynamicMemoryEnabled:$false -StartupBytes 8GB"
Set-VMMemory $DemoVM1 -DynamicMemoryEnabled:$false -StartupBytes 8GB
Start-VM $DemoVM1
Write-Host "`nGet-VM $DemoVM1 | Select Name, ProcessorCount, MemoryMaximum, DynamicMemoryEnabled, NumaAligned, NumaNodesCount, NumaSocketCount`n"
Get-VM $DemoVM1 | Select Name, ProcessorCount, MemoryMaximum, DynamicMemoryEnabled, NumaAligned, NumaNodesCount, NumaSocketCount | Out-Host
Write-Host "`nThe VM now is NUMA aligned and has a NUMA configuration that matches the host hardware" -foregroundcolor red -backgroundcolor yellow
#End the demo
Read-Host "`nEnd the demo"
Stop-VM $DemoVM1 -Force
Set-VMMemory $DemoVM1 -DynamicMemoryEnabled:$true -StartupBytes 512MB -MaximumBytes 8GB -MinimumBytes 256MB
Start-VM $DemoVM1 | Out-Null