How many CPU's and memory should I pass thru to a Windows8 VM?


Recommended Posts

So, I've had my windows8 VM up and running for a couple of days now with no crashes or reboots; YAY!!

 

So, now I'm looking to tweak it for maximum usefulness/benefit.  I have a CPU with 4 cores and no hyperthreading, so I only have 4 cores to use.  I assume I have to leave one for unRAID, so I assume I can pass 3 to the VM, but does that leave me enough processing power for several dockers (SABnzbd, deluge, owncloud, mariadb and nzbdrone).

 

I'm currently passing 2 CPU's and don't have any problems per se, but just want to make sure I'm maximizing the potential of the windows VM, since it's what processes video for all my other computers.

 

Also, I have 8GB of memory in the server, and want at least 4GB for the VM, but maybe even a bit more.  What do I need to leave for unRAID and dockers?  I currently have this for memory in the VM ...

 

<memory unit='KiB'>3906560</memory>
  <currentMemory unit='KiB'>1953128</currentMemory>
  <memoryBacking>

 

The expectation is that it will start with 2GB, then grow as necessary.  The vmMan plugin shows the RAM of the VM at 1.9GB.  Windows task manager shows I'm currently using 2.5 of 3.7GB, without actually doing anything.  I have JRiver Media Center open, but nothing is playing, and there aren't any other machines streaming from it.

 

So, is the 'currentMemory setting even really useful/necessary?  Is 4GB enough memory for Windows8, and is 4GB enough (too much?) for unRAID and several dockers?

 

Advice, suggestions, thoughts are most welcome.

Link to comment

General guidance for Windows 8 would be to have 2 cores and 4GB RAM assigned.  Windows 8 requires ~ 2GB just to boot, so I typically recommend 4GB as a minimum so that you have an extra 2GB for applications and services.

 

I would also advise physically pinning the cores to the vCPUs to prevent the VM from spreading across all 4.  You can do this by using the following in your XML:

 

  <vcpu placement='static'>2</vcpu>
  <cputune>
    <vcpupin vcpu='0' cpuset='2'/>
    <vcpupin vcpu='1' cpuset='3'/>
  </cputune>

 

You have to make sure you have your topology set correctly as well:

 

  <cpu mode='host-passthrough'>
    <topology sockets='1' cores='2' threads='1'/>
  </cpu>

 

Adjust mode= for whatever you currently have (or omit if you have it omitted).  The <topology> section is what's needed in between the <cpu> and </cpu> tag. 

 

Why cores 2 and 3?  First, know that libvirt refers to cores starting with number 0, so your physical cores are 0, 1, 2, and 3.  I like to pin VMs to further out cores given that unRAID likes to utilize the first two cores more than others.  Not a requirement to do it this way, just a suggestion from my own personal experiences.

Link to comment

Thanks jonp, just what I was looking for.

 

I had the cpu tune stuff in my XML already, but had 0 & 1 as my cpuset numbers.  I changed that to 2 & 3, per your advice.  I didn't have <topology sockets='1' cores='2' threads='1'/> in my XML, so I added it.  Finally, I changed the <currentMemory unit='KiB'>1953128</currentMemory> to 4GB.

 

Before making any of these changes, I used the vmMan plugin to shutdown the VM, to test that it was working after updating to the newest version of the plugin.  it worked fine, and shutdown the VM without any drama.

 

So, after making all the changes, and starting the VM, I got something unexpected.  The GPU didn't passthru this time.

 

I knew that I'd have to reboot the server to get GPU passthru working with a windows 7 VM, but I've successfully rebooted the win8 VM several times and had the GPU passthru work every time.  So, when it didn't passthru this time, I am/was surprised.

 

Now, it could be that the changes I made to the XML caused this, or it could be the fact that I shutdown with the vmMan plugin caused this.  I honestly don't know.

 

I'll shutdown the VM, then reboot the server, and then restart the VM to verify it works, then try restarting it from inside windows, as my first test.  if that works, I'll assume it's something to do with the way the vmMan plugin shuts down VM's.  If that's the case, maybe that's why the windows 7 VM isnt' doing GPU passthru without rebooting.

 

I'll report back after a bit of testing, but I wanted to throw this out there, in case it's relevant in testing other stuff, or if anyone knows why this would happen.

Link to comment

okay, so I used the vmMan plugin to shutdown the VM, since it didn't have GPU passthru, i couldn't shutdown from inside windows.

 

the server froze.  I've lost access to the entire server, no GUI, no Putty, no access to shares.

 

Based on other things I've discovered recently, I thought it might be a problem with network saturation, so I disconnected the ethernet cable for a minute, then reconnected, and still don't have access.

 

Now, i have to hard boot the server. :(

Link to comment

okay, so I used the vmMan plugin to shutdown the VM, since it didn't have GPU passthru, i couldn't shutdown from inside windows.

 

the server froze.  I've lost access to the entire server, no GUI, no Putty, no access to shares.

 

Based on other things I've discovered recently, I thought it might be a problem with network saturation, so I disconnected the ethernet cable for a minute, then reconnected, and still don't have access.

 

Now, i have to hard boot the server. :(

If you were running fine for a couple days without a reboot I would remove the cpu pinning for now.  For me cpu pinning always locks up my server. Granted I have a different setup, an 8 core Avoton with no hyperthreading. If your worried about the plugin's shutdown method, it just uses libvirt domain shutdown through php.  It's the same as virsh shutdown vm-name from the command line.

Link to comment

okay, so I used the vmMan plugin to shutdown the VM, since it didn't have GPU passthru, i couldn't shutdown from inside windows.

 

the server froze.  I've lost access to the entire server, no GUI, no Putty, no access to shares.

 

Based on other things I've discovered recently, I thought it might be a problem with network saturation, so I disconnected the ethernet cable for a minute, then reconnected, and still don't have access.

 

Now, i have to hard boot the server. :(

If you were running fine for a couple days without a reboot I would remove the cpu pinning for now.  For me cpu pinning always locks up my server. Granted I have a different setup, an 8 core Avoton with no hyperthreading. If your worried about the plugin's shutdown method, it just uses libvirt domain shutdown through php.  It's the same as virsh shutdown vm-name from the command line.

 

Thanks for the heads up.  After making the changes, we played a video tonight, and it stuttered quite a lot, so I shut down the VM, then I changed the pinning back to 0 & 1 (from 2 & 3) like so...

 

  <cputune>
    <vcpupin vcpu='0' cpuset='0'/>
    <vcpupin vcpu='1' cpuset='1'/>
  </cputune>

 

I also removed this...

 

<topology sockets='1' cores='2' threads='1'/>

 

then I tried to just restart the VM, but it failed with a long warning dialog, so I just rebooted the server, then started the VM, and it's all good again.

 

it seems those settings aren't 'right' for all hardware.  What a nightmare to get this all working right for everyone when nothing seems to be 'set in stone'.  Good luck jonp  ;D8):P

 

Oh well, it seems I'm okay again.  Thanks for all the help.

Link to comment

For a quad core CPU with hyperthreading I assume that is represented by vcpu/cpuset  0-7?

 

Yes.  That is correct.

 

I also assume that with a single CPU that would be:

topology sockets =1 cores=8 threads=1?

Or is it cores=4 threads=2?..

 

Im not having issues, but clarification would be nice.

 

 

No, that isn't correct.  Technically topology just needs to equate to the number of vcpus you assign.  You can mix and match your use of sockets, cores, and threads into almost any variation you want.  The math is this:

 

Number of sockets X number of cores X number of threads = number of vcpus.

 

In all my testing so far, the best config I found actually (using 3DMark benchmarks as a guide) was to use 2 sockets, 4 cores, and 1 thread for an 8 vcpu config.  Not sure why, but I have about 8 pages of testing notes trying every variation of the config and that just yielded the best results...

 

Link to comment

 

 

No, that isn't correct.  Technically topology just needs to equate to the number of vcpus you assign.  You can mix and match your use of sockets, cores, and threads into almost any variation you want.  The math is this:

 

Number of sockets X number of cores X number of threads = number of vcpus.

 

In all my testing so far, the best config I found actually (using 3DMark benchmarks as a guide) was to use 2 sockets, 4 cores, and 1 thread for an 8 vcpu config.  Not sure why, but I have about 8 pages of testing notes trying every variation of the config and that just yielded the best results...

 

Interesting, and also odd!

Thanks for the info, I suppose it is something I will need to play with in order to find the right balance.

From your extensive testing, any "best" combination for a 2 vcpu shared 8.1 VM?

 

Link to comment

 

 

No, that isn't correct.  Technically topology just needs to equate to the number of vcpus you assign.  You can mix and match your use of sockets, cores, and threads into almost any variation you want.  The math is this:

 

Number of sockets X number of cores X number of threads = number of vcpus.

 

In all my testing so far, the best config I found actually (using 3DMark benchmarks as a guide) was to use 2 sockets, 4 cores, and 1 thread for an 8 vcpu config.  Not sure why, but I have about 8 pages of testing notes trying every variation of the config and that just yielded the best results...

 

Interesting, and also odd!

Thanks for the info, I suppose it is something I will need to play with in order to find the right balance.

From your extensive testing, any "best" combination for a 2 vcpu shared 8.1 VM?

As far as topology goes you mean?  Start with 2 sockets, 1 core, and 1 thread.

Link to comment

As far as topology goes you mean?  Start with 2 sockets, 1 core, and 1 thread.

 

Yep, that's what I meant... The 2 sockets is still weird, but whatever works!

 

I just hosed my pass-thru VM for the night, so until a complete power cycle it is broken and I don't feel like doing that right now.

I tried the "restart" from the VM manager, and nope, not so much...

 

The complete shutdown button surprisingly worked well, and VM issued reboots have been working fine also... So, who knows.

Link to comment

My guess is that the best config for 4 vcpus would be: 2 sockets, 2 cores, and 1 thread?

 

Basically looking at an 8 vcpu setup.

 

2 for Unraid

2 for Win 8.1 WMC VM (pinned to cpu2,3) 2 sockets, 1 core, 1 thread

4 for Win 8.1 Gaming VM  (pinned to cpu 4-7) 2 sockets, 2 cores, 1 thread (only on when needed)

4 for Win 8.1 Testing VM (pinned to cpu 4-7) 2 sockets, 2 cores, 1 thread (only on when needed)

 

Testing and Gaming VM's would never be on at the same time.

 

Would you recommend something different?

Link to comment

Sorry, but I have to ask as I have stuttering video performance in my Ubuntu VM (not Windows 8 but I didn't wanted to open another thread for just that little question). This is the CPU that I'm having (test&backup server in my sig).

 

virsh nodeinfo:

CPU model:           x86_64
CPU(s):              4
CPU frequency:       1200 MHz
CPU socket(s):       1
Core(s) per socket:  2
Thread(s) per core:  2
NUMA cell(s):        1
Memory size:         8045380 KiB

 

I have found a pretty good guide on the RedHat site: "For virtual CPUs where vcpupin is not specified, it will be pinned to the physical CPUs specified by cpuset. Each element in the cpuset list is either a single CPU number, a range of CPU numbers, or a caret (^) followed by a CPU number to be excluded from a previous range. The attribute current can be used to specify whether fewer than the maximum number of virtual CPUs should be enabled."

 

<vcpu placement='static' cpuset="1-4,^3,6" current="1">2</vcpu>

 

So in my case, pinning the VM to just one Thread wouldn't it be enough to add this to my XML?

<vcpu placement='static' cpuset="1"</vcpu>

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.