mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Accurately get hardware cpu count in Vagrantfile.
In Vagrantfile replace hack that assumed hyper threading was enabled on the host and divided ncpu by 2 with methods of getting the actual hardware core count.
This commit is contained in:
parent
738f403eea
commit
19224deb04
12
Vagrantfile
vendored
12
Vagrantfile
vendored
@ -70,14 +70,16 @@ $kube_provider_boxes = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# This stuff is cargo-culted from http://www.stefanwrobel.com/how-to-make-vagrant-performance-not-suck
|
# Give access to all physical cpu cores
|
||||||
# Give access to half of all cpu cores on the host. We divide by 2 as we assume
|
# Previously cargo-culted from here:
|
||||||
# that users are running with hyperthreads.
|
# http://www.stefanwrobel.com/how-to-make-vagrant-performance-not-suck
|
||||||
|
# Rewritten to actually determine the number of hardware cores instead of assuming
|
||||||
|
# that the host has hyperthreading enabled.
|
||||||
host = RbConfig::CONFIG['host_os']
|
host = RbConfig::CONFIG['host_os']
|
||||||
if host =~ /darwin/
|
if host =~ /darwin/
|
||||||
$vm_cpus = (`sysctl -n hw.ncpu`.to_i/2.0).ceil
|
$vm_cpus = `sysctl -n hw.physicalcpu`.to_i
|
||||||
elsif host =~ /linux/
|
elsif host =~ /linux/
|
||||||
$vm_cpus = (`nproc`.to_i/2.0).ceil
|
$vm_cpus = `cat /proc/cpuinfo | grep 'core id' | wc -l`.to_i
|
||||||
else # sorry Windows folks, I can't help you
|
else # sorry Windows folks, I can't help you
|
||||||
$vm_cpus = 2
|
$vm_cpus = 2
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user