vagrant-faster icon indicating copy to clipboard operation
vagrant-faster copied to clipboard

Allocating more than 1 core makes VM slower when on VirtualBox

Open luispabon opened this issue 9 years ago • 6 comments

VirtualBox performance degrades when you configure it to use more than one core. This is a known issue with VirtualBox and not fixable from within vagrant I'm afraid.

luispabon avatar Dec 16 '15 14:12 luispabon

I can confirm on OS X. Running my tests on virtualbox took twice as long after I installed vagrant-faster.

btipling avatar Jan 11 '16 20:01 btipling

@luispabon is there an issue you can link to on VirtualBox's bug tracker or something else to show that this is a known issue?

swrobel avatar Jan 17 '16 21:01 swrobel

Read this: http://www.mihaimatei.com/virtualbox-performance-issues-multiple-cpu-cores/

Seems inherent to Virtualbox's architecture.

luispabon avatar Jan 20 '16 14:01 luispabon

After reading the article @luispabon mentions, I did some rudimentary testing and indeed I get significantly better performance (TTFB down from 3-5s to .8s in some instances) by uninstalling this plugin and lowering my cores in Virtualbox from 4 to 1 but keeping RAM high at 3-4GB. My machine has 4 cores and 16GB RAM. Would love to hear the experience of others. Elsewhere in Virtualbox settings, I use KVM as the paravirtualization interface (under System/Acceleration), Execution Cap at 100% (under System/Processor), the ICH9 chipset (under System/Motherboard), and Solid State drive enabled under Storage. In Network, I use Paravirtualized Network (virtio-net) in both Adapter 1 and 2.

ianrobertdouglas avatar Jan 29 '16 00:01 ianrobertdouglas

In my testing this is not the case. On a Mac with 8 cores, I ran extensive apache bench tests against a Ubuntu VM running a complex page without caching and heavy MySQL & Memcache usage 10 concurrent requests for several thousand hits. The results were interesting. So this may be a case-by-case thing.

Important: I also use ioapic which is essential on a 64 bit machine for running multiple cores correctly. vb.customize ["modifyvm", :id, "--ioapic", "on"]

Results: 1 CPU: Requests per second: 0.41 #/sec 2 CPU: Requests per second: 0.57 #/sec 4 CPU: Requests per second: 0.96 #/sec 8 CPU: Requests per second: 0.88 #/sec

There were expected diminishing returns above half the real core count.

heathdutton avatar Oct 12 '16 17:10 heathdutton

@luispabon The article blames hyperthreading, but I don't know about this. In Linux, AFAIK* all the lcores are the same, only pairs of them are mapped onto one physical and will share its resources. The author describes it as some lcores simply being a lot slower than others, meaning you could even just use 1 core and end up with a slow one. Either that's incorrect, or there's something weird going on with the author's host causing that (I don't use Windows and wouldn't know).

* There's lots of misinformation out there. To make sure, I ended up testing myself with a simple program I wrote in C and ran in Linux while pinning it to different lcores.

I've only seen this strange behavior on a macOS host. Linux hosts haven't given me issues, but I've totally given up on running multi-core VirtualBox VMs on my Mac. Just giving a VM 2 cores instead of 1 suddenly makes an Ubuntu Server guest take like 10X longer to boot, and everything seems slower. Haven't tested very much, but for what I know, it could even be an I/O problem; definitely seems like that with even my ls commands lagging.

aleczadikian avatar Oct 31 '17 03:10 aleczadikian