Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package rubygem-concurrent-ruby for openSUSE:Factory checked in at 2024-06-24 20:51:00 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-concurrent-ruby (Old) and /work/SRC/openSUSE:Factory/.rubygem-concurrent-ruby.new.18349 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "rubygem-concurrent-ruby" Mon Jun 24 20:51:00 2024 rev:17 rq:1182769 version:1.3.3 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-concurrent-ruby/rubygem-concurrent-ruby.changes 2024-02-27 22:45:12.627711140 +0100 +++ /work/SRC/openSUSE:Factory/.rubygem-concurrent-ruby.new.18349/rubygem-concurrent-ruby.changes 2024-06-24 20:51:58.049401199 +0200 @@ -1,0 +2,27 @@ +Fri Jun 21 09:41:38 UTC 2024 - Dan Čermák <dan.cermak@posteo.net> + +- ## Release v1.3.3 (9 June 2024) + +* (#1053) Improve the speed of `Concurrent.physical_processor_count` on Windows. + +## Release v1.3.2, edge v0.7.1 (7 June 2024) + +concurrent-ruby: + +* (#1051) Remove dependency on `win32ole`. + +concurrent-ruby-edge: + +* (#1052) Fix dependency on `concurrent-ruby` to allow the latest release. + +## Release v1.3.1 (29 May 2024) + +* Release 1.3.0 was broken when pushed to RubyGems. 1.3.1 is a packaging fix. + +## Release v1.3.0 (28 May 2024) + +* (#1042) Align Java Executor Service behavior for `shuttingdown?`, `shutdown?` +* (#1038) Add `Concurrent.available_processor_count` that is cgroups aware. + + +------------------------------------------------------------------- Old: ---- concurrent-ruby-1.2.3.gem New: ---- concurrent-ruby-1.3.3.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-concurrent-ruby.spec ++++++ --- /var/tmp/diff_new_pack.buKsF1/_old 2024-06-24 20:51:58.645422986 +0200 +++ /var/tmp/diff_new_pack.buKsF1/_new 2024-06-24 20:51:58.649423131 +0200 @@ -24,7 +24,7 @@ # Name: rubygem-concurrent-ruby -Version: 1.2.3 +Version: 1.3.3 Release: 0 %define mod_name concurrent-ruby %define mod_full_name %{mod_name}-%{version} ++++++ concurrent-ruby-1.2.3.gem -> concurrent-ruby-1.3.3.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md --- old/CHANGELOG.md 2024-01-16 10:56:40.000000000 +0100 +++ new/CHANGELOG.md 2024-06-09 16:34:46.000000000 +0200 @@ -1,5 +1,28 @@ ## Current +## Release v1.3.3 (9 June 2024) + +* (#1053) Improve the speed of `Concurrent.physical_processor_count` on Windows. + +## Release v1.3.2, edge v0.7.1 (7 June 2024) + +concurrent-ruby: + +* (#1051) Remove dependency on `win32ole`. + +concurrent-ruby-edge: + +* (#1052) Fix dependency on `concurrent-ruby` to allow the latest release. + +## Release v1.3.1 (29 May 2024) + +* Release 1.3.0 was broken when pushed to RubyGems. 1.3.1 is a packaging fix. + +## Release v1.3.0 (28 May 2024) + +* (#1042) Align Java Executor Service behavior for `shuttingdown?`, `shutdown?` +* (#1038) Add `Concurrent.available_processor_count` that is cgroups aware. + ## Release v1.2.3 (16 Jan 2024) * See [the GitHub release](https://github.com/ruby-concurrency/concurrent-ruby/releases/tag/v1.2.3) for details. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Rakefile new/Rakefile --- old/Rakefile 2024-01-16 10:56:40.000000000 +0100 +++ new/Rakefile 2024-06-09 16:34:46.000000000 +0200 @@ -28,6 +28,10 @@ end end +def which?(executable) + !`which #{executable} 2>/dev/null`.empty? +end + require 'rake_compiler_dock' namespace :repackage do desc '* with Windows fat distributions' @@ -42,12 +46,19 @@ Rake::Task['lib/concurrent-ruby/concurrent/concurrent_ruby.jar'].invoke # build all gem files + rack_compiler_dock_kwargs = {} + if which?('podman') and (!which?('docker') || `docker --version`.include?('podman')) + # podman and only podman available, so RakeCompilerDock will use podman, otherwise it uses docker + rack_compiler_dock_kwargs = { + options: ['--privileged'], # otherwise the directory in the image is empty + runas: false + } + end %w[x86-mingw32 x64-mingw32].each do |plat| RakeCompilerDock.sh( "bundle install --local && bundle exec rake native:#{plat} gem --trace", platform: plat, - options: ['--privileged'], # otherwise the directory in the image is empty - runas: false) + **rack_compiler_dock_kwargs) end end end @@ -256,10 +267,12 @@ Bundler.with_original_env do sh 'ruby -v' + sh 'bundle install' sh 'bundle exec rake spec:installed' - env = { "PATH" => "#{ENV['CONCURRENT_JRUBY_HOME']}/bin:#{ENV['PATH']}" } + env = { "PATH" => "#{ENV.fetch('CONCURRENT_JRUBY_HOME')}/bin:#{ENV['PATH']}" } sh env, 'ruby -v' + sh env, 'bundle install' sh env, 'bundle exec rake spec:installed' end @@ -271,8 +284,8 @@ task :publish => ['publish:ask', 'publish:tag', 'publish:rubygems', 'publish:post_steps'] namespace :publish do - publish_base = true - publish_edge = false + publish_base = nil + publish_edge = nil task :ask do begin @@ -280,8 +293,15 @@ input = STDIN.gets.strip.downcase end until %w(y n).include?(input) exit 1 if input == 'n' + + begin + STDOUT.puts 'Do you want to publish `concurrent-ruby`? (y/n)' + input = STDIN.gets.strip.downcase + end until %w(y n).include?(input) + publish_base = input == 'y' + begin - STDOUT.puts 'It will publish `concurrent-ruby`. Do you want to publish `concurrent-ruby-edge`? (y/n)' + STDOUT.puts 'Do you want to publish `concurrent-ruby-edge`? (y/n)' input = STDIN.gets.strip.downcase end until %w(y n).include?(input) publish_edge = input == 'y' Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ Binary files old/lib/concurrent-ruby/concurrent/concurrent_ruby.jar and new/lib/concurrent-ruby/concurrent/concurrent_ruby.jar differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/concurrent-ruby/concurrent/executor/java_executor_service.rb new/lib/concurrent-ruby/concurrent/executor/java_executor_service.rb --- old/lib/concurrent-ruby/concurrent/executor/java_executor_service.rb 2024-01-16 10:56:40.000000000 +0100 +++ new/lib/concurrent-ruby/concurrent/executor/java_executor_service.rb 2024-06-09 16:34:46.000000000 +0200 @@ -57,15 +57,11 @@ end def ns_shuttingdown? - if @executor.respond_to? :isTerminating - @executor.isTerminating - else - false - end + @executor.isShutdown && !@executor.isTerminated end def ns_shutdown? - @executor.isShutdown || @executor.isTerminated + @executor.isTerminated end class Job diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/concurrent-ruby/concurrent/utility/processor_counter.rb new/lib/concurrent-ruby/concurrent/utility/processor_counter.rb --- old/lib/concurrent-ruby/concurrent/utility/processor_counter.rb 2024-01-16 10:56:40.000000000 +0100 +++ new/lib/concurrent-ruby/concurrent/utility/processor_counter.rb 2024-06-09 16:34:46.000000000 +0200 @@ -11,6 +11,7 @@ def initialize @processor_count = Delay.new { compute_processor_count } @physical_processor_count = Delay.new { compute_physical_processor_count } + @cpu_quota = Delay.new { compute_cpu_quota } end def processor_count @@ -21,6 +22,25 @@ @physical_processor_count.value end + def available_processor_count + cpu_count = processor_count.to_f + quota = cpu_quota + + return cpu_count if quota.nil? + + # cgroup cpus quotas have no limits, so they can be set to higher than the + # real count of cores. + if quota > cpu_count + cpu_count + else + quota + end + end + + def cpu_quota + @cpu_quota.value + end + private def compute_processor_count @@ -48,10 +68,20 @@ end cores.count when /mswin|mingw/ - require 'win32ole' - result_set = WIN32OLE.connect("winmgmts://").ExecQuery( - "select NumberOfCores from Win32_Processor") - result_set.to_enum.collect(&:NumberOfCores).reduce(:+) + # Get-CimInstance introduced in PowerShell 3 or earlier: https://learn.microsoft.com/en-us/previous-versions/powershell/module/cimcmd... + result = run('powershell -command "Get-CimInstance -ClassName Win32_Processor -Property NumberOfCores | Select-Object -Property NumberOfCores"') + if !result || $?.exitstatus != 0 + # fallback to deprecated wmic for older systems + result = run("wmic cpu get NumberOfCores") + end + if !result || $?.exitstatus != 0 + # Bail out if both commands returned something unexpected + processor_count + else + # powershell: "\nNumberOfCores\n-------------\n 4\n\n\n" + # wmic: "NumberOfCores \n\n4 \n\n\n\n" + result.scan(/\d+/).map(&:to_i).reduce(:+) + end else processor_count end @@ -60,6 +90,29 @@ rescue return 1 end + + def run(command) + IO.popen(command, &:read) + rescue Errno::ENOENT + end + + def compute_cpu_quota + if RbConfig::CONFIG["target_os"].include?("linux") + if File.exist?("/sys/fs/cgroup/cpu.max") + # cgroups v2: https://docs.kernel.org/admin-guide/cgroup-v2.html#cpu-interface-files + cpu_max = File.read("/sys/fs/cgroup/cpu.max") + return nil if cpu_max.start_with?("max ") # no limit + max, period = cpu_max.split.map(&:to_f) + max / period + elsif File.exist?("/sys/fs/cgroup/cpu,cpuacct/cpu.cfs_quota_us") + # cgroups v1: https://kernel.googlesource.com/pub/scm/linux/kernel/git/glommer/memcg/+/cpu... + max = File.read("/sys/fs/cgroup/cpu,cpuacct/cpu.cfs_quota_us").to_i + return nil if max == 0 + period = File.read("/sys/fs/cgroup/cpu,cpuacct/cpu.cfs_period_us").to_f + max / period + end + end + end end end @@ -107,4 +160,31 @@ def self.physical_processor_count processor_counter.physical_processor_count end + + # Number of processors cores available for process scheduling. + # Returns `nil` if there is no #cpu_quota, or a `Float` if the + # process is inside a cgroup with a dedicated CPU quota (typically Docker). + # + # For performance reasons the calculated value will be memoized on the first + # call. + # + # @return [nil, Float] number of available processors + def self.available_processor_count + processor_counter.available_processor_count + end + + # The maximum number of processors cores available for process scheduling. + # Returns `nil` if there is no enforced limit, or a `Float` if the + # process is inside a cgroup with a dedicated CPU quota (typically Docker). + # + # Note that nothing prevents setting a CPU quota higher than the actual number of + # cores on the system. + # + # For performance reasons the calculated value will be memoized on the first + # call. + # + # @return [nil, Float] Maximum number of available processors as set by a cgroup CPU quota, or nil if none set + def self.cpu_quota + processor_counter.cpu_quota + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/concurrent-ruby/concurrent/version.rb new/lib/concurrent-ruby/concurrent/version.rb --- old/lib/concurrent-ruby/concurrent/version.rb 2024-01-16 10:56:40.000000000 +0100 +++ new/lib/concurrent-ruby/concurrent/version.rb 2024-06-09 16:34:46.000000000 +0200 @@ -1,3 +1,3 @@ module Concurrent - VERSION = '1.2.3' + VERSION = '1.3.3' end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2024-01-16 10:56:40.000000000 +0100 +++ new/metadata 2024-06-09 16:34:46.000000000 +0200 @@ -1,7 +1,7 @@ --- !ruby/object:Gem::Specification name: concurrent-ruby version: !ruby/object:Gem::Version - version: 1.2.3 + version: 1.3.3 platform: ruby authors: - Jerry D'Antonio @@ -10,7 +10,7 @@ autorequire: bindir: bin cert_chain: [] -date: 2024-01-16 00:00:00.000000000 Z +date: 2024-06-09 00:00:00.000000000 Z dependencies: [] description: | Modern concurrency tools including agents, futures, promises, thread pools, actors, supervisors, and more.