Why does VirtualBox use only half of available CPU power?

This is for discussing general topics about how to use VirtualBox.
Post Reply
Joshua_N
Posts: 1
Joined: 22. Oct 2013, 19:11

Why does VirtualBox use only half of available CPU power?

Post 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?
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

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

Post 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.
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

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

Post 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...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Post Reply