Issue #6615 has been updated by drbrain (Eric Hodel).


=begin
Re-running this last benchmark with only 10,000 files across 50 runs, using ministat from FreeBSD to calculate the decrease in time, the real run time is reduced 2.6% +/- 1.9% at 99% confidence:

  $ ministat -c 99 -s without with
  x without
  + with
  +------------------------------------------------------------------------------+
  |                           +     + +  x    *  xx      x                       |
  |         +     x +   +     +  +  + +  x   **+xx*xx    x * x +               x |
  |+        ++++  x + x*+ * + ++x+x++x*++x* ***+x**xx * +x**** * + x   x       xx|
  |                                |_____________A_____________|                 |
  |                    |______________A_______________|                          |
  +------------------------------------------------------------------------------+
      N           Min           Max        Median           Avg        Stddev
  x  50    0.61660767    0.71641994    0.66669798    0.66647618   0.022548872
  +  50    0.59242272    0.69294882    0.64941692    0.64917859    0.02509235
  Difference at 99.0% confidence
  	-0.0172976 +/- 0.0125332
  	-2.59538% +/- 1.88051%
  	(Student's t, pooled s = 0.0238545)

See http://www.freebsd.org/cgi/man.cgi?query=ministat for the ministat man page

=end

----------------------------------------
Feature #6615: Release GVL in zlib when calling inflate() or deflate()
https://bugs.ruby-lang.org/issues/6615#change-27502

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/