Page 1 of 1

VM CPU Utilization

Posted: 13. May 2009, 06:46
by msmcknight
Hi everyone,

I have Virtualbox v2.2.0 running on Vista Ultimate 64bit and cant seem to get the performance out of my virtual machines that I would like to have.

For some reason, vbox seems to be limited to only 25% of host cpu utilization. Nothing I do within a VM will push the hosts CPU any higher.

I would like to allow the vbox machines to use all 4 cores of my host to the fullest available amount of processing capability the host has to spare.

How can I do this?

Thanks to you all in advance.
-Michael

Re: VM CPU Utilization

Posted: 13. May 2009, 17:14
by Perryg
You are wanting what is called SMP which is not supported yet in VBox. Hopefully it will be out soon but until then you are limited to one core.

Re: VM CPU Utilization

Posted: 13. May 2009, 18:14
by msmcknight
Do all VM's share the same single-core, or can separate VM's make use of other cores?

Thanks again,
Michael

Re: VM CPU Utilization

Posted: 13. May 2009, 19:37
by TerryE
A VMM runs in a process on the host OS. This process only uses one logical core -- that is is only running on one core at any one time. In fact this isn't the same as being tied to a single core since the actual core used is up to the host schedulers and will flip-flop between physical cores. You can have N VMs each running at 100% CPU taking at total of N x 100% of the host capacity (that is assuming you have more than N cores, because at this point you will see resource contention).

Re: VM CPU Utilization

Posted: 14. May 2009, 13:23
by miketrains03
That doesn't totally explain it for me. Any process on the host computer has the default affinity set for all cores. You can manually change it to only use certain cores, but i doubt he did that. If one vm can only use one core, then its something in the virtualbox software limiting it to one core.

Just for shits and giggles, in task manager, make the priority for that vm process as Realtime and make sure the affinity is for all cores. Run prime in the vm and see if your host cpu utilization goes up all the way.

Re: VM CPU Utilization

Posted: 14. May 2009, 14:10
by TerryE
miketrains03 wrote:If one vm can only use one core, then its something in the virtualbox software limiting it to one core.
Mike what you say is precisely correct: The VBox VMM is a currently single core application on the host. You need to add extra code to any application to enable it to run on multiple cores, but before you do you need to be 100% sure that you've sorted out all the code reentrancy issues because it can literally be executing the same area of code on multiple cores at the same time. In the case of a VMM you need to sort out the interoperation with the Host OS scheduler etc, and ensure that you had CPU overload detection (*) sorted.

All of this is far easier to do in a Type I VMM where you have total control over the native kernel and its scheduler / resource management -- which is why IMHO VMware ESX is the only decent SMP virtualisation product at the moment. VMware in their Type II VMware Server product have limit SMP support but if you read the VMware forums their are a lot of grumbles about it actually ending up taking more time to do work than less. Getting SMP VMMs to work well over a standard Linux or Windows host scheduler / kernel is difficult.

That being said I do know that the VBox dev team are looking at adding SMP to VBox, but I suspect that the timescale for this is a 3.x release.

(*) there is an virtualisation overhead with any realtime context switch. The VMM can only idle its VM process if it knows that its guest OS is idling waiting for interupts or its next time slice. My Ubuntu JeOS LAMPs use a 100Hz tick and have no RTC based drivers. Hence when idling, they each take up perhaps 2-4% of a CPU on my host. If your guest has a 1000Hz kernel or is running SMP spin-lock code because you've got an SMP kernel loaded or is using device drivers that use the RealTime clock for scheduling (e.g. Audio and some USB devices) then the VMM will be unable to detect when its idle. As a result we often get posts saying "my guest rns at 100% but its taskmanager shows a utilisation of X (<10) %".