Make Vagrant CPU usage be more sane on hyperthreaded systems.

Fixes #2359
pull/6/head
Joe Beda 2014-11-13 17:09:59 -08:00
parent f8a4bded13
commit 7a6743808a
1 changed files with 4 additions and 4 deletions

8
Vagrantfile vendored
View File

@ -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"]