Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have an 2.8 quad core i7 with a VirtualBox. I have the option of assigning up to 4 cores to a guest machine, but I have only been doing two. What are the advantages/disadvantages of assigning more cores to a guest? BTW, I am still able to play StarCraft 2 on Ultra settings all the way while running two guest OS's (Win 7 and Ubuntu), and same goes with BFBC2 (my stress testers). How does the i7 react to uneven loads accross cores?

share|improve this question

3 Answers 3

up vote 31 down vote accepted

The "virtual" cores you assign to a VM are available to use in multi-processing within the client OS. If you assign only one core to a VM, then there is no chance by the guest OS to distribute load across multiple cores. So let's assume some practical scenarios:

Host with 4 CPUs, guest assigned 1 CPU

  • Host machine running 4 physical cores
  • Client OS within VM assigned 1 core

In this case the guest OS will be able to use only one core. Therefore if you run a multi-threaded application which scales well on multiple cores it will still run on one core only. Therefore all threads on the guest OS have to share one physical core.

Running a guest OS in this setup which fully loads the CPU will yield a host OS CPU load of ~25% (one out of 4 cores loaded on host).

Of course you can still have CPU-consuming tasks running within your host OS and make use of the remaining 3 cores.

Host with 4 CPUs, guest assigned 4 CPUs

  • Host machine running 4 physical cores
  • Client OS within VM assigned 4 cores

In this case you can run well-scaling multi-threaded applications within the guest VM which can make full use of all 4 virtual CPUs. VirtualBox will use 4 physical cores to process tasks scheduled within the VM and therefore your host CPU load could reach a maximum of 100% usage.

So what setting should you chose?

The answer to this question depends pretty much on what you would like to do. In some cases it might be useful to assign all cores to a VM or even running multiple VM having each one the full amount of CPUs assigned. In such cases a VM can make full use of the whole processing power of the host. If more CPUs are assigned to VMs than actually physicall present then the VMs will be impacted by load on different VM. To prevent this you might dedicate some cores to specific VMs. For example running 2 VMs with 2 CPUs assigned each on a 4 core node could help that each VM gets 2 dedicated CPUs (assuming there is no load imposed by host OS which takes a part of the processing-power too).

Does it have negative impact on my host to assign all cores to a VM?

Again this depends on the software run. If you run a VM which is idle (no CPU-intensive programs run at all) the load imposed by this VM will be near to 0%. You can even run 10 VMs in parallel and still experiencing a host CPU load of close to 0% if all VMs are idle.

How does the CPU behave on uneven load?

Well, CPU load distribution heavily depends on an OS-specific built-in component called the scheduler. For Windows XP the scheduler tried to round-robin load all CPU cores. So running a single-threaded task with full load on a quad-core CPU would have yielded ~25% load on each core.
Unfortunately this has proven to be bad for modern CPU power management. For modern systems it's even an advantage if one single core is loaded up to 100% before the second core even gets involved. The reason is that as long as there is not sufficient load to fully use up one core the other cores can remain in deep-sleep mode to save energy and reduce heat dissipation.

For some CPUs like Intel Core i-Series and newer AMD (Bulldozer) this is even more interesting since in case only a subset of the cores are used the unused ones are switched off. This reduces the power consumption of the CPU. Both (Intel and AMD) start to use the thermal and power consumption budget then to overclock the cores which are active. So this can give single-threaded applications (which cannot be distributed to multiple cores to work on a task in parallel) a boost. However when all cores are active then most of these "boost" technologies do have only a small effect on processing power since the "all cores active" situation is exactly the situation the CPU was designed for. But when you switch off some cores then the remaining cores can run overclocked without causing the chip to run more hot (or consuming more power) than in case all cores are active.

So the answer is that your core i7 very well handles uneven load on single cores and might even provide a performance boost to single-threaded applications. However this boost is within the range of a few percent while actually multi-threaded applications which can distribute the load across multiple CPU cores can be boosted by factors (x2 on dual-core, 4x on quad-core...) in optimal case. So multi-threading is always providing more power in terms of combined CPU power than single-threading combined with clock boosting.

share|improve this answer
    
Awesome Response! –  hydroparadise Jun 16 '11 at 15:34
    
Wow, that really helps me understand multi-core behavior, not just how it affects vms. –  Dan Allen Nov 28 '11 at 15:09
1  
I was having a problem with my Ubuntu 12.04 LTS client running really slow on my Macbook Air w/ 2 ghz i7 Dual core. I upped the client's setting to two cpus and now it blazes. I am ignoring the warning message of unoptimal settings . –  Mike Graf Nov 16 '12 at 16:51

I've not delved into the manuals on the VB site, but I'd assume that allocating cores to a guest machine would allow the guest OS to see multiple cores and thus allow applications that can take advantage of those extra cores the added speed/power/efficiency, same as it would for the host OS.

share|improve this answer

Just one note to add to other comments. especially "I am ignoring the warning message of unoptimal settings." from MaerF0x0.

To get rid of that warning message you need to enable IO APIC for your VM. It is under Settings -> System -> Motherboard. I do it myself and my VMs run nice and smooth with an extra core or 2.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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