From 4c0dc9d52e59abc0cedc1898d3ab495bd13998ee Mon Sep 17 00:00:00 2001 From: Watson Date: Tue, 6 Feb 2024 06:08:05 +0900 Subject: [PATCH] Set the using CPU cores limit to compile --- ext/ilios/extconf.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ext/ilios/extconf.rb b/ext/ilios/extconf.rb index d3aada6..355b857 100644 --- a/ext/ilios/extconf.rb +++ b/ext/ilios/extconf.rb @@ -9,18 +9,22 @@ have_func('malloc_usable_size') have_func('malloc_size') +MAX_CORES = 8 + def num_cpu_cores cores = begin if RUBY_PLATFORM.include?('darwin') - Integer(`sysctl -n hw.ncpu`, 10) - 1 + Integer(`sysctl -n hw.ncpu`, 10) else - Integer(`nproc`, 10) - 1 + Integer(`nproc`, 10) end rescue StandardError 2 end - cores.positive? ? cores : 1 + + return 1 if cores <= 0 + cores >= 7 ? MAX_CORES : cores end module LibuvInstaller