Citrix PVS: Optimize endpoint with PowerShell

With Citrix PVS the content of a disk is streamed over the network to an endpoint. This requires sufficient bandwidth and an optimized configuration. If both criteria are not met the endpoint suffers from delays, retries or failures.

Aint-nobody-got-time-for-that_thumb1A number of best practices apply when using Citrix PVS, most of them probably apply for your situation. In the past I had to optimize my VM’s manually each and every time I had to create a new vDisk! Ain’t nobody got time for that (link)!

I wrote a PowerShell script that optimizes the endpoint for Citrix PVS and would like to share it with you.

Updated on October 13th, 2013 with version 1.4

Applied best practices

The script applies a number of best practices to optimize the performance of the PVS endpoint. Some are enabled by default, some are not.

OptimizePVSendpoint-v1.3_thumb1

Disable Task Offload

The most generic best practice that applies for (almost) every PVS environment, disabling all of the task offloads from the TCP/IP transport. See also CTX117491

 

Disable IPv6

vmxnet3-Ethernet-Adapter---Bindings_Although Citrix is working hard to get IPv6 working for all Citrix products, PVS does not support IPv6. Disabling IPv6 on your PVS endpoints prevent intermittent failures. For each network adapter the IPv6 binding is removed using the nvspbind utility. This utility is included in the download. Also, slow boots could occur due to IPv6. See also this TechNet article.

 

Disable TSO and DMA on XenTools

When you’re running your PVS endpoints on Citrix XenServer 5.0 or 5.5 poor target device performance, sluggish mouse responsiveness, application latency and slow moving screen changes might occur. This is a known bug that’s solved in (a hotfix of XenServer 5.6). See also CTX125157.


Increase UDP FastSend threshold

For every UDP packet larger than 1024 bytes, the Windows network stack waits for a transmit completion interrupt before sending the next packet. Unlike for earlier releases, vSphere 5.1 does not provide a transparent workaround of the situation. See also KB2040065

 

Set multiplication factor to the default UDP scavenge value

High CPU usage occurs when a Windows Server 2008 R2-based server is under a very heavy UDP load. This issue occurs because a table is too aggressively scavenged. See also KB2685007

 

Icons are hidden

To prevent users from accessing system tools like the PVS target device software or VMware tools the icons are removed.

 

Disable VMware debug driver

The virtual machine debug driver was disabled for this virtual machine message displays in event log. The virtual machine debug driver is not required in an ESX host. The driver is used for record/play functions in Fusion and Workstation products. See also KB1007652.

Receive Side Scaling is disabled

VMXNET3 resets frequently when RSS is enabled in a multi vCPU Windows virtual machine. When Receive Side Scaling (RSS) is enabled on a multi vCPU Windows virtual machine, you see NetPort messages for repeating MAC addresses indicating that ports are being disabled and then re-enabled. See also KB2055853.

 

Remove non-present NICs

Device-Manager---Network-adapters---[2]After removing a network adapter – for instance to replace an E1000 adapter with a vmxnet3 (because your deployment tool does not support vmxnet3) – the network adapter still exists on your Windows machine. The network adapter is not visible in device manager (see KB241257) but it’s active in the IP stack and, most likely, has a higher priority. As a result the PVS target device software is unable to communicate with the streaming server.

All Ethernet adapters that are not present on the machine are removed using the DevCon utility. The utility is included in the download, in case you lost it make sure you use version 6.1.7600.16385 from the Windows 7 WDK for x64 machines.

Default setting: Enabled



Network Adapter specific optimization

vmxnet3-Ethernet-Adapter_thumb1For each network adapter (E1000, vmxnet3, vmbus, etc.) best practices exists, the most generic is disabling TCP offloading. Depending on the network adapter this has different names and some have more than one feature to disable.

Default setting: Enabled

 

The script changes the following sets the following properties:

Network Adapter Property Value
E1000 (VMware) Large Send Offload (IPv4) Disabled
vmxnet3 (VMware) IPv4 Giant TSO Offload Disabled
IPv4 TSO Offload Disabled
xennet6 (XenServer) Large Send Offload Version 2 (IPv4) Disabled
vmbus (Hyper-V) Large Send Offload Version 2 (IPv4) Disabled
Missing an adapter? Drop me an e-mail at info@ingmarverheij.com

All other properties listed in the Ethernet Adapter Properties dialog can be changed as well. All known properties and values are provided in the script, all you have to do is uncomment (removing the #-character) and set the value you want.  Do NOT enable options before you’ve tested this first and understand what the implications are.

 

Example
You want disable IPv4 Checksum Offload for the vmxnet3 adapter. The default value is 3 (Tx and Rx Enabled), to disable the feature you need to set the value to 0.  In the script go to lines 256, remove the # in front of  ‘Set-ItemProperty’ and set the value “0” and the end of the statement.

# --- IPv4 Checksum Offload ---
$strRegistryKeyName = "*IPChecksumOffloadIPv4"
# 0 - Disabled
# 1 - Tx Enabled
# 2 - Rx Enabled
# 3 - Tx and Rx Enabled (default)
Set-ItemProperty -Path ("HKLM:\SYSTEM\CurrentControlSet\Control\Class\{0}\{1}" -f "{4D36E972-E325-11CE-BFC1-08002BE10318}", ( "{0:D4}" -f $intNICid)) -Name $strRegistryKeyName -Value "0"

 

Tested platforms

The script is tested on multiple hypervisor platforms to ensure it covers the majority of the environments. In case your missing a hypervisor (or a version) feel free to contact me at info@ingmarverheij.com.

  • Citrix XenServer (6.0, 6.02 and 6.2)
  • Microsoft Hyper-V (2.0, 3.0 / 2012)
  • VMware ESX (4.0, 5.0 and 5.1)

 

Usage and download

The script runs without arguments but requires elevated privileges, this is enforced by the script. Within the script you can enable / disable the features in the global options section (eg removing hidden NIC’s or unbinding IPv6). If wanted you can set advanced NIC properties by uncommenting the statement and providing the new value.

You can download the files here: OptimizePVSendpoint

 

.

Thanks

I would like to thank the following people who where kind enough to test the script and provide me with feedback and test data:

  • Kees Baggerman – link
  • Wilco van Bragt – link
  • Iain Brighton – link
  • Tom Gamull – link
  • Andrew Morgan – link
  • Shaun Ritchie – link
  • Jeff Wouters – link
  • Bram Wolfs – link
  • Jonathan Pitre – link

 

 

 

.