New Upstream Release - ruby-parallel
Ready changes
Summary
Merged new upstream version: 1.23.0 (was: 1.22.1).
Resulting package
Built on 2023-05-30T18:53 (took 4m29s)
The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:
apt install -t fresh-releases ruby-parallel
Lintian Result
Diff
diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml
index 0288c40..4728c2a 100644
--- a/.github/workflows/actions.yml
+++ b/.github/workflows/actions.yml
@@ -12,7 +12,7 @@ jobs:
image: mysql
strategy:
matrix:
- ruby: [ '2.5', '2.6', '2.7', '3.0', '3.1' ]
+ ruby: [ '2.5', '2.6', '2.7', '3.0', '3.1', '3.2' ]
task: [ 'spec' ]
include:
- ruby: 2.5 # keep in sync with lowest version
diff --git a/.gitignore b/.gitignore
index b33679f..50133e5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
/rspec.failures
+.ruby-version
diff --git a/Gemfile.lock b/Gemfile.lock
index 4808222..b11b3ad 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- parallel (1.22.1)
+ parallel (1.23.0)
GEM
remote: https://rubygems.org/
@@ -90,4 +90,4 @@ DEPENDENCIES
sqlite3
BUNDLED WITH
- 2.3.9
+ 2.3.12
diff --git a/Readme.md b/Readme.md
index b4c80e8..bc0b58f 100644
--- a/Readme.md
+++ b/Readme.md
@@ -24,10 +24,10 @@ results = Parallel.map(['a','b','c']) do |one_letter|
end
# 3 Processes -> finished after 1 run
-results = Parallel.map(['a','b','c'], in_processes: 3) { |one_letter| ... }
+results = Parallel.map(['a','b','c'], in_processes: 3) { |one_letter| SomeClass.expensive_calculation(one_letter) }
# 3 Threads -> finished after 1 run
-results = Parallel.map(['a','b','c'], in_threads: 3) { |one_letter| ... }
+results = Parallel.map(['a','b','c'], in_threads: 3) { |one_letter| SomeClass.expensive_calculation(one_letter) }
# 3 Ractors -> finished after 1 run
results = Parallel.map(['a','b','c'], in_ractors: 3, ractor: [SomeClass, :expensive_calculation])
@@ -73,11 +73,12 @@ Processes/Threads are workers, they grab the next piece of work when they finish
### Ractors
- Ruby 3.0+ only
- Speedup for blocking operations
- - Variables cannot be shared/modified
- No extra memory used
- Very fast to spawn
- Experimental and unstable
- `start` and `finish` hooks are called on main thread
+ - Variables must be passed in `Parallel.map([1,2,3].map { |i| [i, ARGV, local_var] }, ...`
+ - use `Ractor.make_shareable` to pass in global objects
### ActiveRecord
@@ -165,7 +166,7 @@ Use `Parallel.worker_number` to determine the worker slot in which your
task is running.
```Ruby
-Parallel.each(1..5, :in_processes => 2) { |i| puts "Item: #{i}, Worker: #{Parallel.worker_number}" }
+Parallel.each(1..5, in_processes: 2) { |i| puts "Item: #{i}, Worker: #{Parallel.worker_number}" }
Item: 1, Worker: 1
Item: 2, Worker: 0
Item: 3, Worker: 1
@@ -176,11 +177,9 @@ Item: 5, Worker: 1
Tips
====
-Here are a few notable options.
-
- - [Benchmark/Test] Disable threading/forking with `in_threads: 0` or `in_processes: 0`, great to test performance or to debug parallel issues
+ - [Benchmark/Test] Disable threading/forking with `in_threads: 0` or `in_processes: 0`, to run the same code with different setups
- [Isolation] Do not reuse previous worker processes: `isolation: true`
- - [Stop all processses with an alternate interrupt signal] `'INT'` (from `ctrl+c`) is caught by default. Catch `'TERM'` (from `kill`) with `interrupt_signal: 'TERM'`
+ - [Stop all processes with an alternate interrupt signal] `'INT'` (from `ctrl+c`) is caught by default. Catch `'TERM'` (from `kill`) with `interrupt_signal: 'TERM'`
- [Process count via ENV] `PARALLEL_PROCESSOR_COUNT=16` will use `16` instead of the number of processors detected. This is used to reconfigure a tool using `parallel` without inserting custom logic.
TODO
diff --git a/debian/changelog b/debian/changelog
index eb36348..a9d43e7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+ruby-parallel (1.23.0-1) UNRELEASED; urgency=low
+
+ * New upstream release.
+
+ -- Debian Janitor <janitor@jelmer.uk> Tue, 30 May 2023 18:49:50 -0000
+
ruby-parallel (1.22.1-2) unstable; urgency=medium
* Team upload.
diff --git a/debian/patches/0001-Do-no-use-git.patch b/debian/patches/0001-Do-no-use-git.patch
index 6b900bc..a1f2f71 100644
--- a/debian/patches/0001-Do-no-use-git.patch
+++ b/debian/patches/0001-Do-no-use-git.patch
@@ -6,10 +6,10 @@ Subject: Do no use git
parallel.gemspec | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
-Index: ruby-parallel/parallel.gemspec
+Index: ruby-parallel.git/parallel.gemspec
===================================================================
---- ruby-parallel.orig/parallel.gemspec
-+++ ruby-parallel/parallel.gemspec
+--- ruby-parallel.git.orig/parallel.gemspec
++++ ruby-parallel.git/parallel.gemspec
@@ -14,7 +14,7 @@ Gem::Specification.new name, Parallel::V
"source_code_uri" => "https://github.com/grosser/#{name}/tree/v#{s.version}",
"wiki_uri" => "https://github.com/grosser/#{name}/wiki"
diff --git a/debian/patches/0001-disable-bundler-in-tests.patch b/debian/patches/0001-disable-bundler-in-tests.patch
index 9fafd83..4cab5b5 100644
--- a/debian/patches/0001-disable-bundler-in-tests.patch
+++ b/debian/patches/0001-disable-bundler-in-tests.patch
@@ -6,10 +6,10 @@ Subject: disable bundler in tests
spec/cases/helper.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
-Index: ruby-parallel/spec/cases/helper.rb
+Index: ruby-parallel.git/spec/cases/helper.rb
===================================================================
---- ruby-parallel.orig/spec/cases/helper.rb
-+++ ruby-parallel/spec/cases/helper.rb
+--- ruby-parallel.git.orig/spec/cases/helper.rb
++++ ruby-parallel.git/spec/cases/helper.rb
@@ -1,5 +1,4 @@
# frozen_string_literal: true
-require 'bundler/setup'
diff --git a/lib/parallel.rb b/lib/parallel.rb
index c7f2bf6..e6cec7b 100644
--- a/lib/parallel.rb
+++ b/lib/parallel.rb
@@ -1,11 +1,8 @@
# frozen_string_literal: true
require 'rbconfig'
require 'parallel/version'
-require 'parallel/processor_count'
module Parallel
- extend ProcessorCount
-
Stop = Object.new.freeze
class DeadWorker < StandardError
@@ -307,6 +304,49 @@ module Parallel
map(*args, &block).flatten(1)
end
+ def filter_map(*args, &block)
+ map(*args, &block).compact
+ end
+
+ # Number of physical processor cores on the current system.
+ def physical_processor_count
+ @physical_processor_count ||= begin
+ ppc =
+ case RbConfig::CONFIG["target_os"]
+ when /darwin[12]/
+ IO.popen("/usr/sbin/sysctl -n hw.physicalcpu").read.to_i
+ when /linux/
+ cores = {} # unique physical ID / core ID combinations
+ phy = 0
+ File.read("/proc/cpuinfo").scan(/^physical id.*|^core id.*/) do |ln|
+ if ln.start_with?("physical")
+ phy = ln[/\d+/]
+ elsif ln.start_with?("core")
+ cid = "#{phy}:#{ln[/\d+/]}"
+ cores[cid] = true unless cores[cid]
+ end
+ 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(:+)
+ else
+ processor_count
+ end
+ # fall back to logical count if physical info is invalid
+ ppc > 0 ? ppc : processor_count
+ end
+ end
+
+ # Number of processors seen by the OS, used for process scheduling
+ def processor_count
+ require 'etc'
+ @processor_count ||= Integer(ENV['PARALLEL_PROCESSOR_COUNT'] || Etc.nprocessors)
+ end
+
def worker_number
Thread.current[:parallel_worker_number]
end
diff --git a/lib/parallel/processor_count.rb b/lib/parallel/processor_count.rb
deleted file mode 100644
index 3b5ea61..0000000
--- a/lib/parallel/processor_count.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-# frozen_string_literal: true
-module Parallel
- # TODO: inline this method into parallel.rb and kill physical_processor_count in next major release
- module ProcessorCount
- # Number of processors seen by the OS, used for process scheduling
- def processor_count
- require 'etc'
- @processor_count ||= Integer(ENV['PARALLEL_PROCESSOR_COUNT'] || Etc.nprocessors)
- end
-
- # Number of physical processor cores on the current system.
- def physical_processor_count
- @physical_processor_count ||= begin
- ppc =
- case RbConfig::CONFIG["target_os"]
- when /darwin[12]/
- IO.popen("/usr/sbin/sysctl -n hw.physicalcpu").read.to_i
- when /linux/
- cores = {} # unique physical ID / core ID combinations
- phy = 0
- File.read("/proc/cpuinfo").scan(/^physical id.*|^core id.*/) do |ln|
- if ln.start_with?("physical")
- phy = ln[/\d+/]
- elsif ln.start_with?("core")
- cid = "#{phy}:#{ln[/\d+/]}"
- cores[cid] = true unless cores[cid]
- end
- 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(:+)
- else
- processor_count
- end
- # fall back to logical count if physical info is invalid
- ppc > 0 ? ppc : processor_count
- end
- end
- end
-end
diff --git a/lib/parallel/version.rb b/lib/parallel/version.rb
index 74f1154..94e4e4f 100644
--- a/lib/parallel/version.rb
+++ b/lib/parallel/version.rb
@@ -1,4 +1,4 @@
# frozen_string_literal: true
module Parallel
- VERSION = Version = '1.22.1' # rubocop:disable Naming/ConstantName
+ VERSION = Version = '1.23.0' # rubocop:disable Naming/ConstantName
end
diff --git a/spec/cases/filter_map.rb b/spec/cases/filter_map.rb
new file mode 100644
index 0000000..74f17ba
--- /dev/null
+++ b/spec/cases/filter_map.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+require './spec/cases/helper'
+
+result = Parallel.filter_map(['a', 'b', 'c']) do |x|
+ x if x != 'b'
+end
+print result.inspect
diff --git a/spec/parallel_spec.rb b/spec/parallel_spec.rb
index b4cdfcd..642fffd 100644
--- a/spec/parallel_spec.rb
+++ b/spec/parallel_spec.rb
@@ -540,6 +540,12 @@ describe Parallel do
end
end
+ describe ".filter_map" do
+ it "yields object" do
+ ruby("spec/cases/filter_map.rb 2>&1").should == '["a", "c"]'
+ end
+ end
+
describe ".any?" do
it "returns true if any result is truthy" do
ruby("spec/cases/any_true.rb").split(',').should == ['true'] * 3 * 2
Debdiff
[The following lists of changes regard files as different if they have different names, permissions or owners.]
Files in second set of .debs but not in first
-rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/parallel-1.23.0/lib/parallel.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/parallel-1.23.0/lib/parallel/version.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/specifications/parallel-1.23.0.gemspec
Files in first set of .debs but not in second
-rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/parallel-1.22.1/lib/parallel.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/parallel-1.22.1/lib/parallel/processor_count.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/parallel-1.22.1/lib/parallel/version.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/specifications/parallel-1.22.1.gemspec
No differences were encountered in the control files