Page 1 of 1

VirtualBox not utilising 100% CPU and context switching like crazy

Posted: 8. Jul 2017, 22:13
by giacomogd2
I have a machine with two processors, having 10 physical cores each. The host OS is Debian 9, the guest OS is Ubuntu 16.04. The VM is headless, and configured with bog-standard settings (I changed nothing except of course --cpus 20).

For some reason, when I run "stress --cpu 20" on the guest OS, the 20 VBoxHeadless threads in the host OS seem capped to 90% CPU usage (NB.: the execution cap is 100%)! :shock: They also do a bazillion of voluntary_ctx_switches (10,000 per second :o ).

Can anyone help me figure out what the heck is going on here? Thanks in advance. :D

Re: VirtualBox not utilising 100% CPU and context switching like crazy

Posted: 9. Jul 2017, 00:30
by Martin
You have a host with 20 CPU cores and want to run a guest whith 20 CPUs. Then the host doesn't have a CPU left to handle the running of the VM and needs to switch very often between letting the VM run and handling it.

Re: VirtualBox not utilising 100% CPU and context switching like crazy

Posted: 9. Jul 2017, 00:31
by giacomogd2
Providing fewer virtual CPUs makes no difference.

Re: VirtualBox not utilising 100% CPU and context switching like crazy

Posted: 9. Jul 2017, 08:51
by mpack
Please provide a VM log file. With the VM fully shut down, right click it in GUI. Select "Show Log" and save "VBox.log" (ONLY) to a zip file. Attach the zip here.

Re: VirtualBox not utilising 100% CPU and context switching like crazy

Posted: 9. Jul 2017, 11:35
by giacomogd2
Sure, I'll do it shortly. Just to be clear, there's no GUI: I'll paste here the contents of Logs/Vbox.log.
 Edit: I am sifting through the log to obfuscate usernames, IPs, and other potentially sensitive information. In the meantime, I "solved" the problem by resorting to kvm (which I really didn't want to use, as it is remarkably more convoluted), pinning each virtual core to a physical core, and sharing the NUMA topology with the guest. I now have full CPU utilisation, no context switches, and this is reflected by the performance. 

Re: VirtualBox not utilising 100% CPU and context switching like crazy

Posted: 10. Jul 2017, 09:37
by mpack
If you're obfuscating the log the please don't bother posting it.

Re: VirtualBox not utilising 100% CPU and context switching like crazy

Posted: 10. Jul 2017, 09:51
by giacomogd2
Why? You should see what you're looking for anyway.

Thanks for your help, by the way. :wink:

Re: VirtualBox not utilising 100% CPU and context switching like crazy

Posted: 10. Jul 2017, 09:53
by mpack
Because I don't want to see a log filtered by what you think is important.