Page 1 of 2
VirtualBox only uses maximum 50% CPU
Posted: 10. Feb 2014, 21:27
by chinhodado
On my machine, VirtualBox never uses more than 50% CPU no matter how demanding the task in the Guest is.
When the guest CPU usage reaches 100%, the CPU usage in the host is only 50%
My machine is i7-2600 (4 cores, 8 threads).
In my VM setting I have set the number of processor to 4 (maximum in the green range).
Execution cap is 100%
PAE/NX is enabled
VT-x is enabled, Nested Paging is enabled
Host: Windows 7 x64, Guest: Fedora 20 x64
How can I fix this? I want to utilize 100% of my machine's CPU.
Re: VirtualBox only uses maximum 50% CPU
Posted: 10. Feb 2014, 23:18
by Reinderien
Have you tried doubling the number of CPUs assigned to the guest? Even though your CPU may have 4 cores, to Linux I believe it should look like 8 due to Hyperthreading.
Re: VirtualBox only uses maximum 50% CPU
Posted: 10. Feb 2014, 23:51
by chinhodado
I can set the number of processors up to 8, but if I set it more than 4 VirtualBox will display a warning:
Invalid settings detected: More virtual CPUs are assigned to the virtual machine than the number of physical CPUs on the host system (4). This is likely to degrade the performance of your virtual machine. Please consider reducing the number of virtual CPUs
Re: VirtualBox only uses maximum 50% CPU
Posted: 10. Feb 2014, 23:55
by Reinderien
Try it anyway.
Re: VirtualBox only uses maximum 50% CPU
Posted: 11. Feb 2014, 00:16
by chinhodado
I tried it, and it does work (the CPU usage is now more than 50%). However isn't it discouraged by VirtualBox? I mean, if I can just do it without any drawbacks, what's the point of the warning?
Re: VirtualBox only uses maximum 50% CPU
Posted: 11. Feb 2014, 00:39
by Reinderien
I think that the warning is bogus.
Re: VirtualBox only uses maximum 50% CPU
Posted: 11. Feb 2014, 00:50
by Perryg
Not bogus. It is there to prevent you having issues with the host. It says warning not fatal.
Once you have an issue with over-committing the CPU you will understand and heed the warning.
Re: VirtualBox only uses maximum 50% CPU
Posted: 11. Feb 2014, 17:08
by Reinderien
I agree that over-committing your CPU is an issue, but in this case, vbox is incorrectly assuming that your capacity for concurrent threads is equal to your core count, and this is clearly not the case with Hyperthreading. You could even set the CPU count to 7, trigger the warning, and it would be physically impossible to pin the CPU at 100%.
Re: VirtualBox only uses maximum 50% CPU
Posted: 13. Feb 2014, 14:21
by noteirak
The green mark is set to your physical cores, they are the only thing that truely matter in the end.
The orange mark is set to your logical cores, because they share ressources with the physical cores, and therefore it's never truely possible to run two things totally unrelated at the same time on these.
The red mark is the additions of the two, and is clearly over-commitement.
The matter is not how much of CPU% you reach, but how busy you keep your CPU by switching contexts and the likes. So going above your physical cores is always a bad idea if you know you'll do intensive tasks.
Re: VirtualBox only uses maximum 50% CPU
Posted: 13. Feb 2014, 16:14
by chinhodado
Sorry, is this orange or red?
Also, are you saying that even though the CPU utilization is higher (by selecting more cores), the performance is not actually better? That seems counter-intuitive.
Re: VirtualBox only uses maximum 50% CPU
Posted: 13. Feb 2014, 16:27
by Perryg
VirtualBox deals with physical cores. Hyper-threads ( SMT ) are not cores, but appear as cores due to the way they are implemented. Adding yet another outlet to a pipeline does not mean you have additional cores, just paths to the core/s that you do have.
Re: VirtualBox only uses maximum 50% CPU
Posted: 13. Feb 2014, 16:32
by chinhodado
So you mean this is true?
even though the CPU utilization is higher (by selecting more cores), the performance is not actually better?
Re: VirtualBox only uses maximum 50% CPU
Posted: 13. Feb 2014, 17:03
by Perryg
To a point yes. The overhead of adding a core quickly becomes more than the advantage. The only way to find the optimal setting for your PC is to test adding one at a time and use a stop watch to see when degradation happens. Monitors ( such as are shown above ) are not accurate when used in/with virtualization.
Now when you add threads you are telling VBox to use the same core twice and that can cause issues since VBox does not use HT ( hypter-threads ). Intel even tells you that you should disable HT on units that do not use them. Do some reading about HT's and you will see what I am talking about.
Re: VirtualBox only uses maximum 50% CPU
Posted: 13. Feb 2014, 17:09
by socratis
chinhodado wrote:So you mean this is true?
even though the CPU utilization is higher (by selecting more cores), the performance is not actually better?
Well, yes and no. I did a little test a while back with a number crunching program. The performance was more or less linear. But there was no other I/O. You can read all about it here:
viewtopic.php?f=1&t=59259&start=15
Re: VirtualBox only uses maximum 50% CPU
Posted: 13. Feb 2014, 17:18
by chinhodado
socratis wrote:chinhodado wrote:So you mean this is true?
even though the CPU utilization is higher (by selecting more cores), the performance is not actually better?
Well, yes and no. I did a little test a while back with a number crunching program. The performance was more or less linear. But there was no other I/O. You can read all about it here:
viewtopic.php?f=1&t=59259&start=15
So according to your result, the performance will linearly increase as the number of cores approaches the number of logical cores on your machine right? That's what I think as well.
One more thing: on your machine, do you have the green bar all the way up tp 8 cores? Or just to 4 like on my machine?