Skip to content

Commit

Permalink
Set the using CPU cores limit to compile
Browse files Browse the repository at this point in the history
  • Loading branch information
Watson1978 committed Feb 5, 2024
1 parent 66e29e0 commit 4c0dc9d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ext/ilios/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4c0dc9d

Please sign in to comment.