mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 10:19:50 +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
|
# 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']
|
host = RbConfig::CONFIG['host_os']
|
||||||
if host =~ /darwin/
|
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/
|
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
|
else # sorry Windows folks, I can't help you
|
||||||
$vm_cpus = 2
|
$vm_cpus = 2
|
||||||
end
|
end
|
||||||
@ -41,7 +42,6 @@ end
|
|||||||
# Give VM 512MB of RAM
|
# Give VM 512MB of RAM
|
||||||
$vm_mem = 512
|
$vm_mem = 512
|
||||||
|
|
||||||
|
|
||||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||||
def customize_vm(config)
|
def customize_vm(config)
|
||||||
config.vm.box = $kube_box[$kube_os]["name"]
|
config.vm.box = $kube_box[$kube_os]["name"]
|
||||||
|
Loading…
Reference in New Issue
Block a user