You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

concurrent-ruby

Package Overview
Dependencies
Maintainers
3
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

concurrent-ruby - rubygems Package Compare versions

Comparing version
1.3.3
to
1.3.4
+5
-0
CHANGELOG.md
## Current
## Release v1.3.4 (10 August 2024)
* (#1060) Fix bug with return value of `Concurrent.available_processor_count` when `cpu.cfs_quota_us` is -1.
* (#1058) Add `Concurrent.cpu_shares` that is cgroups aware.
## Release v1.3.3 (9 June 2024)

@@ -4,0 +9,0 @@

+5
-5
source 'https://rubygems.org'
require File.join(File.dirname(__FILE__), 'lib/concurrent-ruby/concurrent/version')
require File.join(File.dirname(__FILE__ ), 'lib/concurrent-ruby-edge/concurrent/edge/version')
version = File.read("#{__dir__}/lib/concurrent-ruby/concurrent/version.rb")[/'(.+)'/, 1] or raise
edge_version = File.read("#{__dir__}/lib/concurrent-ruby-edge/concurrent/edge/version.rb")[/'(.+)'/, 1] or raise

@@ -9,5 +9,5 @@ no_path = ENV['NO_PATH']

gem 'concurrent-ruby', Concurrent::VERSION, options
gem 'concurrent-ruby-edge', Concurrent::EDGE_VERSION, options
gem 'concurrent-ruby-ext', Concurrent::VERSION, options.merge(platform: :mri)
gem 'concurrent-ruby', version, options
gem 'concurrent-ruby-edge', edge_version, options
gem 'concurrent-ruby-ext', version, options.merge(platform: :mri)

@@ -14,0 +14,0 @@ group :development do

@@ -15,2 +15,3 @@ require 'etc'

@cpu_quota = Delay.new { compute_cpu_quota }
@cpu_shares = Delay.new { compute_cpu_shares }
end

@@ -45,2 +46,6 @@

def cpu_shares
@cpu_shares.value
end
private

@@ -83,3 +88,3 @@

else
# powershell: "\nNumberOfCores\n-------------\n 4\n\n\n"
# powershell: "\nNumberOfCores\n-------------\n 4\n\n\n"
# wmic: "NumberOfCores \n\n4 \n\n\n\n"

@@ -113,3 +118,5 @@ result.scan(/\d+/).map(&:to_i).reduce(:+)

max = File.read("/sys/fs/cgroup/cpu,cpuacct/cpu.cfs_quota_us").to_i
return nil if max == 0
# If the cpu.cfs_quota_us is -1, cgroup does not adhere to any CPU time restrictions
# https://docs.kernel.org/scheduler/sched-bwc.html#management
return nil if max <= 0
period = File.read("/sys/fs/cgroup/cpu,cpuacct/cpu.cfs_period_us").to_f

@@ -120,2 +127,16 @@ max / period

end
def compute_cpu_shares
if RbConfig::CONFIG["target_os"].include?("linux")
if File.exist?("/sys/fs/cgroup/cpu.weight")
# cgroups v2: https://docs.kernel.org/admin-guide/cgroup-v2.html#cpu-interface-files
# Ref: https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/2254-cgroup-v2#phase-1-convert-from-cgroups-v1-settings-to-v2
weight = File.read("/sys/fs/cgroup/cpu.weight").to_f
((((weight - 1) * 262142) / 9999) + 2) / 1024
elsif File.exist?("/sys/fs/cgroup/cpu/cpu.shares")
# cgroups v1: https://kernel.googlesource.com/pub/scm/linux/kernel/git/glommer/memcg/+/cpu_stat/Documentation/cgroups/cpu.txt
File.read("/sys/fs/cgroup/cpu/cpu.shares").to_f / 1024
end
end
end
end

@@ -136,4 +157,4 @@ end

# invocation of the virtual machine... [applications] should therefore
# occasionally poll this property." Subsequently the result will NOT be
# memoized under JRuby.
# occasionally poll this property." We still memoize this value once under
# JRuby.
#

@@ -171,4 +192,5 @@ # Otherwise Ruby's Etc.nprocessors will be used.

# 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).
# This method takes in account the CPU quota if the process is inside a cgroup with a
# dedicated CPU quota (typically Docker).
# Otherwise it returns the same value as #processor_count but as a Float.
#

@@ -178,3 +200,3 @@ # For performance reasons the calculated value will be memoized on the first

#
# @return [nil, Float] number of available processors
# @return [Float] number of available processors
def self.available_processor_count

@@ -198,2 +220,10 @@ processor_counter.available_processor_count

end
# The CPU shares requested by the process. For performance reasons the calculated
# value will be memoized on the first call.
#
# @return [Float, nil] CPU shares requested by the process, or nil if not set
def self.cpu_shares
processor_counter.cpu_shares
end
end
module Concurrent
VERSION = '1.3.3'
VERSION = '1.3.4'
end
+22
-19

@@ -1,4 +0,3 @@

require_relative 'lib/concurrent-ruby/concurrent/version'
require_relative 'lib/concurrent-ruby-edge/concurrent/edge/version'
require_relative 'lib/concurrent-ruby/concurrent/utility/engine'
version = File.read("#{__dir__}/lib/concurrent-ruby/concurrent/version.rb")[/'(.+)'/, 1] or raise
edge_version = File.read("#{__dir__}/lib/concurrent-ruby-edge/concurrent/edge/version.rb")[/'(.+)'/, 1] or raise

@@ -11,3 +10,3 @@ core_gemspec = Gem::Specification.load File.join(__dir__, 'concurrent-ruby.gemspec')

ENV['JRUBY_HOME'] = ENV['CONCURRENT_JRUBY_HOME'] if ENV['CONCURRENT_JRUBY_HOME'] && !Concurrent.on_jruby?
ENV['JRUBY_HOME'] = ENV['CONCURRENT_JRUBY_HOME'] if ENV['CONCURRENT_JRUBY_HOME'] && RUBY_ENGINE != 'jruby'

@@ -19,3 +18,3 @@ Rake::JavaExtensionTask.new('concurrent_ruby', core_gemspec) do |ext|

unless Concurrent.on_jruby? || Concurrent.on_truffleruby?
if RUBY_ENGINE == 'ruby'
require 'rake/extensiontask'

@@ -73,3 +72,3 @@

Gem::PackageTask.new(core_gemspec) {} if core_gemspec
Gem::PackageTask.new(ext_gemspec) {} if ext_gemspec && !Concurrent.on_jruby?
Gem::PackageTask.new(ext_gemspec) {} if ext_gemspec && RUBY_ENGINE != 'jruby'
Gem::PackageTask.new(edge_gemspec) {} if edge_gemspec

@@ -102,5 +101,5 @@

Dir.chdir(__dir__) do
sh "gem install pkg/concurrent-ruby-#{Concurrent::VERSION}.gem"
sh "gem install pkg/concurrent-ruby-ext-#{Concurrent::VERSION}.gem" if Concurrent.on_cruby?
sh "gem install pkg/concurrent-ruby-edge-#{Concurrent::EDGE_VERSION}.gem"
sh "gem install pkg/concurrent-ruby-#{version}.gem"
sh "gem install pkg/concurrent-ruby-ext-#{version}.gem" if RUBY_ENGINE == 'ruby'
sh "gem install pkg/concurrent-ruby-edge-#{edge_version}.gem"
ENV['NO_PATH'] = 'true'

@@ -135,3 +134,3 @@ sh 'bundle update'

current_yard_version_name = Concurrent::VERSION
current_yard_version_name = version

@@ -240,2 +239,4 @@ begin

task :checks do
raise '$CONCURRENT_JRUBY_HOME must be set' unless ENV['CONCURRENT_JRUBY_HOME']
Dir.chdir(__dir__) do

@@ -271,2 +272,4 @@ sh 'test -z "$(git status --porcelain)"' do |ok, res|

task :test do
raise '$CONCURRENT_JRUBY_HOME must be set' unless ENV['CONCURRENT_JRUBY_HOME']
Dir.chdir(__dir__) do

@@ -320,6 +323,6 @@ puts "Testing with the installed gem"

Dir.chdir(__dir__) do
sh "git tag v#{Concurrent::VERSION}" if publish_base
sh "git push origin v#{Concurrent::VERSION}" if publish_base
sh "git tag edge-v#{Concurrent::EDGE_VERSION}" if publish_edge
sh "git push origin edge-v#{Concurrent::EDGE_VERSION}" if publish_edge
sh "git tag v#{version}" if publish_base
sh "git push origin v#{version}" if publish_base
sh "git tag edge-v#{edge_version}" if publish_edge
sh "git push origin edge-v#{edge_version}" if publish_edge
end

@@ -331,7 +334,7 @@ end

Dir.chdir(__dir__) do
sh "gem push pkg/concurrent-ruby-#{Concurrent::VERSION}.gem" if publish_base
sh "gem push pkg/concurrent-ruby-edge-#{Concurrent::EDGE_VERSION}.gem" if publish_edge
sh "gem push pkg/concurrent-ruby-ext-#{Concurrent::VERSION}.gem" if publish_base
sh "gem push pkg/concurrent-ruby-ext-#{Concurrent::VERSION}-x64-mingw32.gem" if publish_base
sh "gem push pkg/concurrent-ruby-ext-#{Concurrent::VERSION}-x86-mingw32.gem" if publish_base
sh "gem push pkg/concurrent-ruby-#{version}.gem" if publish_base
sh "gem push pkg/concurrent-ruby-edge-#{edge_version}.gem" if publish_edge
sh "gem push pkg/concurrent-ruby-ext-#{version}.gem" if publish_base
sh "gem push pkg/concurrent-ruby-ext-#{version}-x64-mingw32.gem" if publish_base
sh "gem push pkg/concurrent-ruby-ext-#{version}-x86-mingw32.gem" if publish_base
end

@@ -338,0 +341,0 @@ end

Sorry, the diff of this file is not supported yet