1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

default.mspec: limit cores

* spec/default.mspec (MSpecScript::JobServer#cores): limit max
  number of processors, not to acquire tokens more than necessary.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-06-16 23:59:33 +00:00
parent 2875337533
commit 9bf9d0ef42
3 changed files with 8 additions and 7 deletions

View file

@ -24,15 +24,16 @@ class MSpecScript
end
module MSpecScript::JobServer
def cores
if /(?:\A|\s)--jobserver-(?:auth|fds)=(\d+),(\d+)/ =~ ENV["MAKEFLAGS"]
cores = 0
def cores(max = 1)
if max > 1 and /(?:\A|\s)--jobserver-(?:auth|fds)=(\d+),(\d+)/ =~ ENV["MAKEFLAGS"]
cores = 1
begin
r = IO.for_fd($1.to_i(10), "rb", autoclose: false)
w = IO.for_fd($2.to_i(10), "wb", autoclose: false)
jobtokens = r.read_nonblock(1024)
jobtokens = r.read_nonblock(max - 1)
cores = jobtokens.size
if cores > 0
cores += 1
jobserver = w
w = nil
at_exit {

View file

@ -98,7 +98,7 @@ class MSpecMain < MSpecScript
end
output_files = []
processes = [cores, @files.size].min
processes = cores(@files.size)
children = processes.times.map { |i|
name = tmp "mspec-multi-#{i}"
output_files << name

View file

@ -234,9 +234,9 @@ class MSpecScript
files patterns
end
def cores
def cores(max = 1)
require 'etc'
Etc.nprocessors
[Etc.nprocessors, max].min
end
def setup_env