parallel 0.8.1 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 10b1b5e1d603d7fd6d85c66526c729295b864bf6
4
- data.tar.gz: 864604781d56f1f70df314de0e8af937a8b73dc8
3
+ metadata.gz: 1b4969ff4fcd994e10d9e2269f674ba78b3fc302
4
+ data.tar.gz: 749ec2527f60964c8e248c67c2a7b506be74292c
5
5
  SHA512:
6
- metadata.gz: f263eb9456018b8959bd3f7875775ae954f8b4736914ed59bae9d4f34f2becc42b2858a4e23900dacb35a84e89f5f349b861dc18214540be770bf6d939ea24eb
7
- data.tar.gz: 8dbf0fbe7f583b2de1987b47082ab81ac6d198b6ca7d429969b7b416e346f01d1dc06d4d040f8962c26f8b69eb0e474980481547e065afe3b53841b4fec8b2eb
6
+ metadata.gz: c91534ca1aa69298ac99bb37545655d71266f0d18d57326b0cd89e1afc5c151c6907a34ada4829f7eea22c6d641eb7f5c10da09315f9ed524a7aba789b1d1cfa
7
+ data.tar.gz: b543711832ef16a348e0ea8aec4f28fa319f9ad662d08b79597fcc6b5e2fdd08c79ed8692da417cf1d9895018d371235135fdb8508321731e3ccdb672c283797
data/.travis.yml CHANGED
@@ -1,6 +1,4 @@
1
1
  language: ruby
2
- before_script:
3
- - export TRAVIS=1
4
2
  rvm:
5
3
  - 1.8.7
6
4
  - 1.9.3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- parallel (0.8.1)
4
+ parallel (0.8.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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
- result = call_with_index(items, index, options, &block)
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
- result = ExceptionWrapper.new(e)
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
- block.call(*args)
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)
@@ -1,3 +1,3 @@
1
1
  module Parallel
2
- VERSION = Version = '0.8.1'
2
+ VERSION = Version = '0.8.2'
3
3
  end
@@ -0,0 +1,5 @@
1
+ require File.expand_path('spec/spec_helper')
2
+
3
+ Parallel.each(1..1000, :in_threads => 2) do |i|
4
+ "xxxx" * 1_000_000
5
+ end
@@ -1,4 +1,4 @@
1
- require File.expand_path('spec/spec_helper')
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
- $LOAD_PATH.unshift 'lib'
2
- require 'parallel'
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.1
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-10 00:00:00.000000000 Z
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