Page 1 of 1

Why does VirtualBox use only half of available CPU power?

Posted: 22. Oct 2013, 19:40
by Joshua_N
I can't get the guest system running in VirtualBox to use 100% of CPU processing power when I configure VirtualBox to use 4 cores. I use Intel Core i7-3770K, which is a 4-core CPU with 2 threads per core. "Windows Task Manager" in the host operating systems shows 8 available CPUs, because it sees a thread as a "CPU".

VirtualBox version: 4.3.0
Host operating system: Windows 7 64 bit
Guest operating system: Ubuntu 12.04 64 bit

To test, I compile LLVM using "make -j8" or "make -j16". This should utilize 100% of available CPU, but both Windows Task Manager and Process Explorer on the host OS report that VirtualBox uses exactly 50% of CPU power. I can only get the guest system running in VirtualBox to use 100% of available CPU when compiling LLVM or doing other parallel tasks if I set VirtualBox to use 8 CPUs, which VirtualBox reports as an incorrect configuration.

What should I do to make the guest system utilize multi-threading?

Re: Why does VirtualBox use only half of available CPU power

Posted: 23. Oct 2013, 12:13
by mpack
Do you know anything about how multi-core CPUs work?

Most applications are single threaded, at least for the main execution path that does all the work. It all runs on one core. It won't notice additional cores: which if added will likely make the VM slow down, not speed up.

It also makes a difference what your CPU monitor considers available CPU. If 100% would require all 8 threads to be running flat out then that is usually physically impossible, because the threads conflict (they're an illusion of pipelining, there is no actual additional computing power available).

Finally, if you don't want your host to grind to a halt you need to give it some CPU time as well.

Tip: start with one core and time it. Then time the effect of adding additional cores - to a maximum of 3, since that's all you have available.

Re: Why does VirtualBox use only half of available CPU power

Posted: 24. Oct 2013, 07:41
by socratis
Joshua_N wrote:... I configure VirtualBox to use 4 cores ... host operating systems shows 8 available CPUs ... both Windows Task Manager and Process Explorer on the host OS report that VirtualBox uses exactly 50% of CPU power
Well, you have 8 "virtual" CPUs on the host, you assign 4 on the guest and it uses 50%. It kind of makes sense, doesn't it? The only thing that throws your description off is that the guest is showing 50% CPU utilization. I have a 4 dual core system (i.e. it shows as 8 CPUs on the host) and a guest (WinXP) that is doing some heavy lifting with 4 CPUs assigned. When the guest is running, it shows 100% CPU on all 4 CPUs and the host shows 50% overall with 4 out of 8 cores maxed out. As mpack said, if I assign 6 cores, it actually slows down both guest and host.

I tried to upload some screenshots to illustrate what's going on, but the forum won't let me...