Page 1 of 1

VirtualBox priority (NICE) - how to decicate 1 core to guest

Posted: 28. Jan 2009, 09:21
by vuser1
Hello!

I need to give my win2003 guest the maximum possible CPU performance - regardless of the host machine workload. I know that VBox cannot eat both CPU cores, it uses 1 core maximum for 1 VM. In fact, this could be even better condition for me than SMP.

Idea is to give the guest full access to 1 host cpu core by raising VBox process priority (niceness). This ensures that guest never be slow even if server runs some big workload (I plan to install OpenVZ-based web-server on host).

This is safe as well - in case of big workload inside guest, the host will still have 1 core because of VBox cannot use both cores.

Everything looks perfect, but see what is in real life (host - ubuntu 8.04):
1. I run "renice -10 ..." against VBoxHeadless process.
2. I run "stress -c 20", effectively starting 20 threads on HOST
3. I run "cpustres" inside GUEST and run 4 threads.
4. On the HOST - the "top" output shows:
* 20 'stress' with nice=0
* 1 'VBoxHeadless' with nice=-10
* all the 21 processes receives almost equal CPU amount! It looks like nice -10 has no effect at all.

If I run "nice +10 stress" on host, then VBoxHeadless has 40% CPU, but still not 100% (full 1 core).

It differs a lot from the way process priority works on windows.

Why it works as above? Is this how it should work or something is wrong? How could I guarantee that guest receives as much CPU as it wants (from 1 core)?

Posted: 28. Jan 2009, 12:40
by Sasquatch
If you really want the best performance for your server 2003, run it native, not in a VM. Changing the priority will only cause it to get a higher chance of CPU use when needed, it does not boost the speed of your VM.

Posted: 28. Jan 2009, 18:02
by vuser1
This is exactly what I need! I need a guarantee that it never be slow, under no circumstances. This is actually my "workplace" - and I want it to be responsive regardless of other server's load. But no need of top performance.

Re: VirtualBox priority (NICE) - how to decicate 1 core to guest

Posted: 3. Apr 2009, 03:17
by es1
I know it is long time since this thread started but I would suggest testing the cpuset feature of the linux kernel (Included ON in some distros).
start by 'mkdir /cpuset ; mount -t cpuset none /cpuset/' and read the documentation (kernel documentation: .../Documentation/cpusets.txt)
The Idea that drives this feature is that you can define sets of CPUs and confine process and kernel threads to specific set (/sys set by default)
then other applications (like the VirtualBox) can run on the other CPUs, it will be more interesting on Quad systems, where you can limit the hosting
to single core, while the VirtualBox's VMs to run on the other cores.
I hope it helps you in the right direction. 8)