mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
Make Vagrant CPU usage be more sane on hyperthreaded systems.
Fixes #2359
This commit is contained in:
parent
f8a4bded13
commit
7a6743808a
8
Vagrantfile
vendored
8
Vagrantfile
vendored
@ -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"]
|
||||
|
Loading…
Reference in New Issue
Block a user