VirtualBox, and possibly other VM software, allows the user to specify the number of CPUs exposed to the VM. In my particular case, I have a dual core CPU, with Windows 7 64-bit running natively, and Ubuntu 9.04 64-bit as the VM.

The help file suggests not setting this above the number of physical cores available. This makes sense. So, is it best allocating 1 or 2 CPU cores? Does this depend entirely on the native CPU load?

link|improve this question

60% accept rate
feedback

6 Answers

up vote 4 down vote accepted

It entirely depends on what the guest OS is doing. In my personal experience a VM is running a single program (build server, trac server, SVN, etc) so there is no reason to set it above one.

A possible case may be if it's an end user on say a University that is using the guest OS as a throwaway (i.e. TAs) then maybe set it to higher than one.

link|improve this answer
So, in other words: for a temporary system, you may as well max out the CPU core quota; but for "normal" or typical use, set it to one core (so not to interfere too much with the performance of the host OS)? – sblair Aug 12 '09 at 21:04
feedback

The number of cores exposed to guest CPUs does not affect performance as much as you would like. It merely adjusts the amount of cores the guest CPU "sees".

Depending on how the emulator is set up, it could literally half the performance of the virtual machine, do nothing, or only impact the way the guest OS/applications split up their thread scheduling.

It's best to leave it to the default. If you encounter performance issues on the host PC, then you can simply adjust the process priority with the Windows Task Manager.

link|improve this answer
feedback

You should never assign all your cores as vCPUs in a virtual machine.

If a VM requests any CPU time, VMWare has to allocate either all the vCPUs, or none of the vCPUs.

What this means is, on a 4-core system if you allocate all 4 cores, then only either the host, or the guest, can be allocated processor time, not both at the same time.

This will absolutally ruin performance in both environments.

Feel free to allocate an odd-number of cores (say, 3). It feels odd, but it's a totally legitimate option.

Generally I never allocate more than (n/2) vCPUs (in your case, 2) - but I'm normally allocating cores on servers with between 12 and 32 cores where you can allocate huge numbers of vCPUs without major impact.

link|improve this answer
this is the only answer thus far written with any degree of authority. thanks for sharing your experiences. – gWiz Apr 12 at 15:57
feedback

I'd trust the OS's scheduler and just set the VM to the # of physical cores, unless you Know that you always want the host to have a potentially idle core while you're busy in the VM.

link|improve this answer
feedback

This depends on what you want to do on the virtual machine as well as on the physical machine. If you need to use the virtual machine while the host operating system is being used for some other activity, it may be better to use two processor cores for the VM so that the host has two remaining if the VM is under full load. On the other hand, if you are working primarily on the VM, you can use all processor cores.

However, unless the guest can be expected to use all four cores at once, you can safely use all of them while continuing to work on the host OS.

link|improve this answer
This is based on my experience with VirtualBox. As I am not familiar with VMware products, I may be wrong; if so, I'll delete this answer. – DragonLord Apr 21 '11 at 13:20
feedback

yes, I'd also say that it depends. But I'll say what I prefer to do. At work I have a quad core CPU. So for my virtual image (win7), I've allocated two CPUs. That way, I can use both the host machine and the virtual machine at the same time, and they each have equal CPU resources.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.