From 7a6743808a34505792be6f452aa9e1ec346c417b Mon Sep 17 00:00:00 2001 From: Joe Beda Date: Thu, 13 Nov 2014 17:09:59 -0800 Subject: [PATCH] Make Vagrant CPU usage be more sane on hyperthreaded systems. Fixes #2359 --- Vagrantfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 3cb4badfbfc1d..5be613efe45f4 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -28,12 +28,13 @@ $kube_box = { } # This stuff is cargo-culted from http://www.stefanwrobel.com/how-to-make-vagrant-performance-not-suck -# Give access to all cpu cores on the host +# Give access to half of all cpu cores on the host. We divide by 2 as we assume +# that users are running with hyperthreads. host = RbConfig::CONFIG['host_os'] if host =~ /darwin/ - $vm_cpus = `sysctl -n hw.ncpu`.to_i + $vm_cpus = (`sysctl -n hw.ncpu`.to_i/2.0).ceil elsif host =~ /linux/ - $vm_cpus = `nproc`.to_i + $vm_cpus = (`nproc`.to_i/2.0).ceil else # sorry Windows folks, I can't help you $vm_cpus = 2 end @@ -41,7 +42,6 @@ end # Give VM 512MB of RAM $vm_mem = 512 - Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| def customize_vm(config) config.vm.box = $kube_box[$kube_os]["name"]