ruby-changes:46441
From: normal <ko1@a...>
Date: Thu, 4 May 2017 11:13:16 +0900 (JST)
Subject: [ruby-changes:46441] normal:r58556 (trunk): benchmark: new single-threaded read/write benchmark with pipe
normal 2017-05-04 11:13:11 +0900 (Thu, 04 May 2017) New Revision: 58556 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58556 Log: benchmark: new single-threaded read/write benchmark with pipe This is currently for testing GVL performance in the uncontended case: IO#write and IO#read unconditionally release GVL for blocking I/O with pipe. It will also be interesting to see how this changes if we switch to M:N threading model. Added files: trunk/benchmark/bm_io_pipe_rw.rb Index: benchmark/bm_io_pipe_rw.rb =================================================================== --- benchmark/bm_io_pipe_rw.rb (nonexistent) +++ benchmark/bm_io_pipe_rw.rb (revision 58556) @@ -0,0 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/benchmark/bm_io_pipe_rw.rb#L1 +# Measure uncontended GVL performance via read/write with 1:1 threading +# If we switch to M:N threading, this will benchmark something else... +r, w = IO.pipe +src = '0'.freeze +dst = String.new +i = 0 +while i < 1_000_000 + i += 1 + w.write(src) + r.read(1, dst) +end +w.close +r.close -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/