Jump to content
dlandon

Performance Improvements in VMs by adjusting CPU pinning and assignment

214 posts in this topic Last Reply

Recommended Posts

Update: moving the emulator off core 0 seems to have fixed my audio lag in youtube and the plex web app - excellent!

Share this post


Link to post
Posted (edited)

I'm hoping someone can assist me with this issue. I've pinned a VM to 6 (logical) cores, but only 3 cores appear to be actively used. How would I go about fixing this?

 

CPU is: E5-2670

 

 

CPU activity - handbrake.PNG

task-manager.PNG

VM cpu-pinning.PNG

Edited by RParkerMU
changed to logical cores

Share this post


Link to post

Check 6 boxes instead of 3

Sent from my SM-G955U using Tapatalk

  • Upvote 3

Share this post


Link to post
23 minutes ago, david279 said:

Check 6 boxes instead of 3 emoji848.png

Sent from my SM-G955U using Tapatalk
 

 

Edited my response to logical cores.

Share this post


Link to post
Posted (edited)

post the xml of your VM also run msconfig;boot;advanced options to see if its using the correct amount of cores in Windows.

Edited by david279

Share this post


Link to post

Below is a copy of my XML. It doesn't appear as if Windows is seeing the other cores. The attached screenshot is from task manager on the VM, which shows 3 virtual CPUs and no logical cores. Advanced options of msconfig also only show 3 processors.

 

<domain type='kvm'>
  <name>Media-VM</name>
  <uuid>f462ab30-bd7b-879b-98f9-12fd29a6febf</uuid>
  <metadata>
    <vmtemplate xmlns="unraid" name="Windows 10" icon="windows.png" os="windows10"/>
  </metadata>
  <memory unit='KiB'>4194304</memory>
  <currentMemory unit='KiB'>2097152</currentMemory>
  <memoryBacking>
    <nosharepages/>
  </memoryBacking>
  <vcpu placement='static'>3</vcpu>
  <cputune>
    <vcpupin vcpu='0' cpuset='11'/>
    <vcpupin vcpu='1' cpuset='4'/>
    <vcpupin vcpu='2' cpuset='13'/>
  </cputune>
  <os>
    <type arch='x86_64' machine='pc-i440fx-2.11'>hvm</type>
    <loader readonly='yes' type='pflash'>/usr/share/qemu/ovmf-x64/OVMF_CODE-pure-efi.fd</loader>
    <nvram>/etc/libvirt/qemu/nvram/f462ab30-bd7b-879b-98f9-12fd29a6febf_VARS-pure-efi.fd</nvram>
  </os>
  <features>
    <acpi/>
    <apic/>
    <hyperv>
      <relaxed state='on'/>
      <vapic state='on'/>
      <spinlocks state='on' retries='8191'/>
      <vendor_id state='on' value='none'/>
    </hyperv>
  </features>
  <cpu mode='host-passthrough' check='none'>
    <topology sockets='1' cores='3' threads='1'/>
  </cpu>
  <clock offset='localtime'>
    <timer name='hypervclock' present='yes'/>
    <timer name='hpet' present='no'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/local/sbin/qemu</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writeback'/>
      <source file='/mnt/user/domains/Media-VM/vdisk1.img'/>
      <target dev='hdc' bus='virtio'/>
      <boot order='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/mnt/user/isos/Windows/Windows 10 (1803) x64.iso'/>
      <target dev='hda' bus='sata'/>
      <readonly/>
      <boot order='2'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/mnt/user/isos/virtio-win-0.1.141.iso'/>
      <target dev='hdb' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
    <controller type='usb' index='0' model='ich9-ehci1'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x7'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <master startport='0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0' multifunction='on'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <master startport='2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x1'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci3'>
      <master startport='4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'/>
    <controller type='ide' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <controller type='sata' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </controller>
    <controller type='virtio-serial' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </controller>
    <interface type='bridge'>
      <mac address='52:54:00:24:e9:5f'/>
      <source bridge='br0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <target type='isa-serial' port='0'>
        <model name='isa-serial'/>
      </target>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <channel type='unix'>
      <target type='virtio' name='org.qemu.guest_agent.0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
    <input type='tablet' bus='usb'>
      <address type='usb' bus='0' port='1'/>
    </input>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes' websocket='-1' listen='0.0.0.0' keymap='en-us'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>
    <video>
      <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1' primary='yes'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </memballoon>
  </devices>
</domain>

 

task-manager.PNG

Share this post


Link to post
12 minutes ago, RParkerMU said:

Below is a copy of my XML. It doesn't appear as if Windows is seeing the other cores. The attached screenshot is from task manager on the VM, which shows 3 virtual CPUs and no logical cores. Advanced options of msconfig also only show 3 processors.

 


<domain type='kvm'>
  <name>Media-VM</name>
  <uuid>f462ab30-bd7b-879b-98f9-12fd29a6febf</uuid>
  <metadata>
    <vmtemplate xmlns="unraid" name="Windows 10" icon="windows.png" os="windows10"/>
  </metadata>
  <memory unit='KiB'>4194304</memory>
  <currentMemory unit='KiB'>2097152</currentMemory>
  <memoryBacking>
    <nosharepages/>
  </memoryBacking>
  <vcpu placement='static'>3</vcpu>
  <cputune>
    <vcpupin vcpu='0' cpuset='11'/>
    <vcpupin vcpu='1' cpuset='4'/>
    <vcpupin vcpu='2' cpuset='13'/>
  </cputune>
  <os>
    <type arch='x86_64' machine='pc-i440fx-2.11'>hvm</type>
    <loader readonly='yes' type='pflash'>/usr/share/qemu/ovmf-x64/OVMF_CODE-pure-efi.fd</loader>
    <nvram>/etc/libvirt/qemu/nvram/f462ab30-bd7b-879b-98f9-12fd29a6febf_VARS-pure-efi.fd</nvram>
  </os>
  <features>
    <acpi/>
    <apic/>
    <hyperv>
      <relaxed state='on'/>
      <vapic state='on'/>
      <spinlocks state='on' retries='8191'/>
      <vendor_id state='on' value='none'/>
    </hyperv>
  </features>
  <cpu mode='host-passthrough' check='none'>
    <topology sockets='1' cores='3' threads='1'/>
  </cpu>
  <clock offset='localtime'>
    <timer name='hypervclock' present='yes'/>
    <timer name='hpet' present='no'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/local/sbin/qemu</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writeback'/>
      <source file='/mnt/user/domains/Media-VM/vdisk1.img'/>
      <target dev='hdc' bus='virtio'/>
      <boot order='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/mnt/user/isos/Windows/Windows 10 (1803) x64.iso'/>
      <target dev='hda' bus='sata'/>
      <readonly/>
      <boot order='2'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/mnt/user/isos/virtio-win-0.1.141.iso'/>
      <target dev='hdb' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
    <controller type='usb' index='0' model='ich9-ehci1'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x7'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <master startport='0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0' multifunction='on'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <master startport='2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x1'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci3'>
      <master startport='4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'/>
    <controller type='ide' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <controller type='sata' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </controller>
    <controller type='virtio-serial' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </controller>
    <interface type='bridge'>
      <mac address='52:54:00:24:e9:5f'/>
      <source bridge='br0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <target type='isa-serial' port='0'>
        <model name='isa-serial'/>
      </target>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <channel type='unix'>
      <target type='virtio' name='org.qemu.guest_agent.0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
    <input type='tablet' bus='usb'>
      <address type='usb' bus='0' port='1'/>
    </input>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes' websocket='-1' listen='0.0.0.0' keymap='en-us'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>
    <video>
      <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1' primary='yes'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </memballoon>
  </devices>
</domain>

 

task-manager.PNG

 

 

windows knows its a virtual machine, hence you getting virtual cores. Declaring a topology doesn't matter in a windows vm environment. it uses all assigned cores the same.

Share this post


Link to post

Your xml only list cpus 11,4,13. So its only gonna use those cpus. You need to add 3,5 and 12.

  • Upvote 1

Share this post


Link to post
58 minutes ago, RParkerMU said:

@1812 Any idea why cores 3, 5 & 12 are not being utilized?

 

 

Picture to highlight what others said. You need to click on 6 Check Boxes. You only clicked on 3 check boxes. You're only giving it 3 resources, not 6.

 

Try6CheckBoxesNot3.png.184f71188fe9666e09ee1e1c26e0e905.png

 

 

Share this post


Link to post
Posted (edited)
16 minutes ago, BRiT said:

 

 

Picture to highlight what others said. You need to click on 6 Check Boxes. You only clicked on 3 check boxes. You're only giving it 3 resources, not 6.

 

Try6CheckBoxesNot3.png.184f71188fe9666e09ee1e1c26e0e905.png

 

 

 

Thanks for adding the arrows. I feel like an idiot for completely missing those check boxes.

Edited by RParkerMU
extra s
  • Upvote 1

Share this post


Link to post
On 7/20/2018 at 3:43 AM, smashingtool said:

How should CPU pinning be handled on a ryzen chip? I assume the CCX makes it slightly more complicated. I guess the real question is, what is the layout of the CPU/Threads for 1-16?

 

Did you ever find any info on this? I find my VMs are a bit "buggy" (best way I can think to describe it). I have a TR1950x and assign 8/16 to a Windows VM  leaving the 1st 8/16 to unRAID and the dockers. But still can find my VM experience isn't perfect. I wonder if the Ryzen family CCX mapping or core numbering isn't quite the same as the default for Intel systems.....   (or maybe I have some other issue I have yet to spot!)

Share this post


Link to post
On ‎9‎/‎6‎/‎2018 at 3:00 AM, methanoid said:

 

Did you ever find any info on this? I find my VMs are a bit "buggy" (best way I can think to describe it). I have a TR1950x and assign 8/16 to a Windows VM  leaving the 1st 8/16 to unRAID and the dockers. But still can find my VM experience isn't perfect. I wonder if the Ryzen family CCX mapping or core numbering isn't quite the same as the default for Intel systems.....   (or maybe I have some other issue I have yet to spot!)

I was wondering that same thing.  I have spun up a few more machines on my 1920x and ever since I have added an extra machine for game hosting, my IO seems slower and every once in a while, some machines will fail installs complaining about writing to the vhdx file that contains my steam libraries. I have only pinned CPUs to the 5 VMs that I have running, and not done any isolation or docker pinning.  I am only running one docker right now for steamcache bundle.

 

What is recommended for our threadrippers?  Should I have isolation on for the first 2 cores/4ht? 

Share this post


Link to post

Isolating cores is to prevent unraid to use them for backround tasks or for docker. So for best performance in a VM you have to isolate the cores you wanna pin to your VM. Keep in mind core 0 is always used by unraid and you can't isolate this one. Also keep in mind always isolate the core + its HT. In my case i have a 1950x. 2 dies each with 8cores. I isolated all 8 cores from the second die which I use for my main Win10 VM. The rest of the cores are used by Unraid, Docker and some VMs i use from time to time.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now