[#45426] [ruby-trunk - Feature #6546][Open] Net::HTTP to check for HTTP_PROXY environment setting. — "dekz (Jacob Evans)" <dekzter@...>

14 messages 2012/06/04

[#45431] [ruby-trunk - Bug #6548][Open] Rake doesn't ignore arguments after -- — "rosenfeld (Rodrigo Rosenfeld Rosas)" <rr.rosas@...>

12 messages 2012/06/05

[#45474] [ANN] Request for "slide-show" of your feature proposal — Yusuke Endoh <mame@...>

(Japanese later; 日本語が後にあります)

18 messages 2012/06/07

[#45563] [ruby-trunk - Bug #6573][Open] Webrick test failures — "bkabrda (Bohuslav Kabrda)" <bkabrda@...>

19 messages 2012/06/11

[#45567] [ruby-trunk - Bug #6575][Open] Thread#kill sets rb_errinfo() to Fixnum 8 after rb_protect(function, data, &error_tag) — ibc (Iñaki Baz Castillo) <ibc@...>

9 messages 2012/06/11

[#45647] [ruby-trunk - Bug #6592][Open] test_call_double(DL::TestDL) fails on ARM HardFP — "vo.x (Vit Ondruch)" <v.ondruch@...>

15 messages 2012/06/14

[#45657] [ruby-trunk - Feature #6594][Open] Integrated Functor — "trans (Thomas Sawyer)" <transfire@...>

20 messages 2012/06/15

[#45664] [ruby-trunk - Bug #6596][Open] New method for Arrays : Array#index — "robin850 (Robin Dupret)" <robin.dupret@...>

20 messages 2012/06/15

[#45694] [ruby-trunk - Feature #6602][Open] Tail call optimization: enable by default? — "ko1 (Koichi Sasada)" <redmine@...>

12 messages 2012/06/18

[#45715] [ruby-trunk - Feature #6609][Open] Toplevel as self extended module — "trans (Thomas Sawyer)" <transfire@...>

17 messages 2012/06/19

[#45732] [ruby-trunk - Bug #6614][Open] GC doesn't collect objects bound to (collectable) proc — "rogerdpack (Roger Pack)" <rogerpack2005@...>

9 messages 2012/06/20

[#45733] [ruby-trunk - Feature #6615][Open] Release GVL in zlib when calling inflate() or deflate() — "drbrain (Eric Hodel)" <[email protected]>

12 messages 2012/06/21

[#45735] [ruby-trunk - Bug #6616][Open] MinGW: cannot build extensions or run tests due changes in exec_arg? — "luislavena (Luis Lavena)" <luislavena@...>

9 messages 2012/06/21

[#45798] [ruby-trunk - Bug #6634][Open] Deadlock with join and ConditionVariable — "meh. (meh. I don't care)" <meh@...>

20 messages 2012/06/23

[#45805] [ruby-trunk - Feature #6636][Open] Enumerable#size — "marcandre (Marc-Andre Lafortune)" <ruby-core@...>

15 messages 2012/06/23

[#45864] [ruby-trunk - Bug #6647][Open] Exceptions raised in threads should be logged — "headius (Charles Nutter)" <headius@...>

71 messages 2012/06/25

[#45902] [ruby-trunk - Bug #6653][Open] 1.9.2/1.9.3 exhibit SEGV with many threads+tcp connections — "erikh (Erik Hollensbe)" <erik@...>

11 messages 2012/06/26

[#45960] [ruby-trunk - Feature #6669][Open] A method like Hash#map but returns hash — "yhara (Yutaka HARA)" <redmine@...>

18 messages 2012/06/29

[#45963] [ruby-trunk - Feature #6670][Open] str.chars.last should be possible — "yhara (Yutaka HARA)" <redmine@...>

36 messages 2012/06/29

[#46021] [ruby-trunk - Feature #6679][Open] Default Ruby source file encoding to utf-8 — "claytrump (Clay Trump)" <clay.trump@...>

21 messages 2012/06/30

[ruby-core:45900] [ruby-trunk - Feature #6615] Release GVL in zlib when calling inflate() or deflate()

From: "drbrain (Eric Hodel)" <[email protected]>
Date: 2012-06-26 21:57:17 UTC
List: ruby-core #45900
Issue #6615 has been updated by drbrain (Eric Hodel).


Since the last benchmark is so close, this benchmark uses the same deflate file set, but adds GVL contention by deflating the set across four threads.  Since no buffer expansion occurs this will benchmark cost of GVL release vs rb_thread_schedule() in present Zlib code.

Code:

  require 'zlib'
  require 'benchmark'
  
  r = Random.new 0
  
  file_count = 100_000
  
  deflated = (0..file_count).map do
    input = r.bytes 1000
    Zlib::Deflate.deflate input
  end
  
  times = Benchmark.measure do
    (0..3).map do
      Thread.new do
        deflated.each do |input|
          Zlib::Inflate.inflate input
        end
      end
    end.each do |t|
      t.join
    end
  end
  
  puts times

Without patch:

$ for f in `jot 5`; do ruby20 test.rb; done
  5.420000   5.970000  11.390000 (  8.162893)
  5.400000   6.270000  11.670000 (  8.263046)
  5.460000   5.920000  11.380000 (  8.133742)
  5.410000   6.290000  11.700000 (  8.289913)
  5.500000   6.620000  12.120000 (  8.478085)

With patch:

$ for f in `jot 5`; do make runruby; done
  5.120000   6.240000  11.360000 (  8.039715)
  5.240000   6.260000  11.500000 (  8.097961)
  5.280000   5.940000  11.220000 (  8.004246)
  5.210000   6.360000  11.570000 (  8.171124)
  5.240000   6.200000  11.440000 (  8.054929)

Again, slight improvement, but not as great as the video.

The inflate function is able to operate in parallel a small fraction of the time which is able to make up for the cost of GVL release/acquire.
----------------------------------------
Feature #6615: Release GVL in zlib when calling inflate() or deflate()
https://bugs.ruby-lang.org/issues/6615#change-27500

Author: drbrain (Eric Hodel)
Status: Open
Priority: Normal
Assignee: 
Category: ext
Target version: 2.0.0


This patch switches from zstream_run from using rb_thread_schedule() to rb_thread_blocking_region().

I don't see a way to safely interrupt deflate() or inflate() so the unblocking function is empty.

This patch should allow use of output buffer sizes larger than 16KB.  I suspect 16KB was chosen to allow reasonable context-switching time for ruby 1.8 and earlier.  A larger buffer size would reduce GVL contention when processing large streams.

An alternate way to reduce GVL contention would be to move zstream_run's loop outside the GVL, but some manual allocation would be required as currently the loop uses a ruby String as the output buffer.


-- 
http://bugs.ruby-lang.org/

In This Thread