Skip to content

Commit

Permalink
Make Vagrant CPU usage be more sane on hyperthreaded systems.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeda committed Nov 14, 2014
1 parent f8a4bde commit 7a67438
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ $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

# 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"]
Expand Down

0 comments on commit 7a67438

Please sign in to comment.