ruby-changes:46989
From: nobu <ko1@a...>
Date: Sat, 17 Jun 2017 08:59:40 +0900 (JST)
Subject: [ruby-changes:46989] nobu:r59103 (trunk): default.mspec: limit cores
nobu 2017-06-17 08:59:33 +0900 (Sat, 17 Jun 2017) New Revision: 59103 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59103 Log: default.mspec: limit cores * spec/default.mspec (MSpecScript::JobServer#cores): limit max number of processors, not to acquire tokens more than necessary. Modified files: trunk/spec/default.mspec trunk/spec/mspec/lib/mspec/commands/mspec.rb trunk/spec/mspec/lib/mspec/utils/script.rb Index: spec/mspec/lib/mspec/utils/script.rb =================================================================== --- spec/mspec/lib/mspec/utils/script.rb (revision 59102) +++ spec/mspec/lib/mspec/utils/script.rb (revision 59103) @@ -234,9 +234,9 @@ class MSpecScript https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/utils/script.rb#L234 files patterns end - def cores + def cores(max = 1) require 'etc' - Etc.nprocessors + [Etc.nprocessors, max].min end def setup_env Index: spec/mspec/lib/mspec/commands/mspec.rb =================================================================== --- spec/mspec/lib/mspec/commands/mspec.rb (revision 59102) +++ spec/mspec/lib/mspec/commands/mspec.rb (revision 59103) @@ -98,7 +98,7 @@ class MSpecMain < MSpecScript https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/commands/mspec.rb#L98 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 Index: spec/default.mspec =================================================================== --- spec/default.mspec (revision 59102) +++ spec/default.mspec (revision 59103) @@ -24,15 +24,16 @@ class MSpecScript https://github.com/ruby/ruby/blob/trunk/spec/default.mspec#L24 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 { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/