parallel 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -2
- data/Gemfile.lock +1 -1
- data/lib/parallel.rb +9 -5
- data/lib/parallel/version.rb +1 -1
- data/spec/cases/no_gc_with_each.rb +5 -0
- data/spec/parallel_spec.rb +5 -1
- data/spec/spec_helper.rb +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b4969ff4fcd994e10d9e2269f674ba78b3fc302
|
4
|
+
data.tar.gz: 749ec2527f60964c8e248c67c2a7b506be74292c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c91534ca1aa69298ac99bb37545655d71266f0d18d57326b0cd89e1afc5c151c6907a34ada4829f7eea22c6d641eb7f5c10da09315f9ed524a7aba789b1d1cfa
|
7
|
+
data.tar.gz: b543711832ef16a348e0ea8aec4f28fa319f9ad662d08b79597fcc6b5e2fdd08c79ed8692da417cf1d9895018d371235135fdb8508321731e3ccdb672c283797
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
data/lib/parallel.rb
CHANGED
@@ -270,11 +270,10 @@ module Parallel
|
|
270
270
|
def process_incoming_jobs(read, write, items, options, &block)
|
271
271
|
while !read.eof?
|
272
272
|
index = Marshal.load(read)
|
273
|
-
begin
|
274
|
-
|
275
|
-
result = nil if options[:preserve_results] == false
|
273
|
+
result = begin
|
274
|
+
call_with_index(items, index, options, &block)
|
276
275
|
rescue Exception => e
|
277
|
-
|
276
|
+
ExceptionWrapper.new(e)
|
278
277
|
end
|
279
278
|
Marshal.dump(result, write)
|
280
279
|
end
|
@@ -342,7 +341,12 @@ module Parallel
|
|
342
341
|
def call_with_index(array, index, options, &block)
|
343
342
|
args = [array[index]]
|
344
343
|
args << index if options[:with_index]
|
345
|
-
|
344
|
+
if options[:preserve_results] == false
|
345
|
+
block.call(*args)
|
346
|
+
nil # avoid GC overhead of passing large results around
|
347
|
+
else
|
348
|
+
block.call(*args)
|
349
|
+
end
|
346
350
|
end
|
347
351
|
|
348
352
|
def with_instrumentation(item, index, options)
|
data/lib/parallel/version.rb
CHANGED
data/spec/parallel_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Parallel do
|
4
4
|
def time_taken
|
@@ -279,6 +279,10 @@ describe Parallel do
|
|
279
279
|
it "does not use marshal_dump" do
|
280
280
|
`ruby spec/cases/no_dump_with_each.rb 2>&1`.should == 'no dump for resultno dump for each'
|
281
281
|
end
|
282
|
+
|
283
|
+
it "does not slow down with lots of GC work in threads" do
|
284
|
+
Benchmark.realtime { `ruby spec/cases/no_gc_with_each.rb 2>&1` }.should <= 10
|
285
|
+
end
|
282
286
|
end
|
283
287
|
|
284
288
|
describe ".each_with_index" do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
2
|
-
require '
|
1
|
+
require 'parallel'
|
2
|
+
require 'benchmark'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parallel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: michael@grosser.it
|
@@ -41,6 +41,7 @@ files:
|
|
41
41
|
- spec/cases/map_with_threads_and_break.rb
|
42
42
|
- spec/cases/map_with_threads_and_exceptions.rb
|
43
43
|
- spec/cases/no_dump_with_each.rb
|
44
|
+
- spec/cases/no_gc_with_each.rb
|
44
45
|
- spec/cases/parallel_fast_exit.rb
|
45
46
|
- spec/cases/parallel_high_fork_rate.rb
|
46
47
|
- spec/cases/parallel_influence_outside_data.rb
|