* 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
Родитель 2875337533
Коммит 9bf9d0ef42
3 изменённых файлов: 8 добавлений и 7 удалений

Просмотреть файл

@ -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 {

Просмотреть файл

@ -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

Просмотреть файл

@ -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