ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:20191] [Bug #806] Net::Protocol#rbuf_fill is slow
@ 2008-12-01 18:22 Aaron Patterson
  2008-12-02  6:28 ` [ruby-core:20198] " Yukihiro Matsumoto
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Aaron Patterson @ 2008-12-01 18:22 UTC (permalink / raw
  To: ruby-core

Bug #806: Net::Protocol#rbuf_fill is slow
http://redmine.ruby-lang.org/issues/show/806

Author: Aaron Patterson
Status: Open, Priority: Normal
Category: lib

Net::Protocol#rbuf_fill is slow.  We can take advantage of io.read_nonblock and IO.select to deal with timeouts.

I've attached a patch.


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:20198] [Bug #806] Net::Protocol#rbuf_fill is slow
  2008-12-01 18:22 [ruby-core:20191] [Bug #806] Net::Protocol#rbuf_fill is slow Aaron Patterson
@ 2008-12-02  6:28 ` Yukihiro Matsumoto
  2008-12-02  6:31 ` [ruby-core:20199] [Bug #806](Closed) " Yukihiro Matsumoto
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Yukihiro Matsumoto @ 2008-12-02  6:28 UTC (permalink / raw
  To: ruby-core

Issue #806 has been updated by Yukihiro Matsumoto.


merged.  report if any problem caused by this patch.
----------------------------------------
http://redmine.ruby-lang.org/issues/show/806

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:20199] [Bug #806](Closed) Net::Protocol#rbuf_fill is slow
  2008-12-01 18:22 [ruby-core:20191] [Bug #806] Net::Protocol#rbuf_fill is slow Aaron Patterson
  2008-12-02  6:28 ` [ruby-core:20198] " Yukihiro Matsumoto
@ 2008-12-02  6:31 ` Yukihiro Matsumoto
  2009-02-07  4:27 ` [ruby-core:21905] [Bug #806] " Jeremy Kemper
  2009-03-03 11:37 ` [ruby-core:22642] " Matthew Ford
  3 siblings, 0 replies; 5+ messages in thread
From: Yukihiro Matsumoto @ 2008-12-02  6:31 UTC (permalink / raw
  To: ruby-core

Issue #806 has been updated by Yukihiro Matsumoto.

Status changed from Open to Closed
% Done changed from 0 to 100

Applied in changeset r20443.
----------------------------------------
http://redmine.ruby-lang.org/issues/show/806

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:21905] [Bug #806] Net::Protocol#rbuf_fill is slow
  2008-12-01 18:22 [ruby-core:20191] [Bug #806] Net::Protocol#rbuf_fill is slow Aaron Patterson
  2008-12-02  6:28 ` [ruby-core:20198] " Yukihiro Matsumoto
  2008-12-02  6:31 ` [ruby-core:20199] [Bug #806](Closed) " Yukihiro Matsumoto
@ 2009-02-07  4:27 ` Jeremy Kemper
  2009-03-03 11:37 ` [ruby-core:22642] " Matthew Ford
  3 siblings, 0 replies; 5+ messages in thread
From: Jeremy Kemper @ 2009-02-07  4:27 UTC (permalink / raw
  To: ruby-core

Issue #806 has been updated by Jeremy Kemper.


Breaks if the IO doesn't respond to read_nonblock. StringIO, for example. Fall back to sysread in that case:

Index: lib/net/protocol.rb
===================================================================
--- lib/net/protocol.rb	(revision 22024)
+++ lib/net/protocol.rb	(working copy)
@@ -131,14 +131,20 @@
     BUFSIZE = 1024 * 16
 
     def rbuf_fill
-      begin
-        @rbuf << @io.read_nonblock(BUFSIZE)
-      rescue Errno::EWOULDBLOCK
-        if IO.select([@io], nil, nil, @read_timeout)
-          retry
-        else
-          raise Timeout::TimeoutError
+      if @io.respond_to?(:read_nonblock)
+        begin
+          @rbuf << @io.read_nonblock(BUFSIZE)
+        rescue Errno::EWOULDBLOCK
+          if IO.select([@io], nil, nil, @read_timeout)
+            retry
+          else
+            raise Timeout::TimeoutError
+          end
         end
+      else
+        timeout(@read_timeout) do
+          @rbuf << @io.sysread(BUFSIZE)
+        end
       end
     end
 


----------------------------------------
http://redmine.ruby-lang.org/issues/show/806

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:22642] [Bug #806] Net::Protocol#rbuf_fill is slow
  2008-12-01 18:22 [ruby-core:20191] [Bug #806] Net::Protocol#rbuf_fill is slow Aaron Patterson
                   ` (2 preceding siblings ...)
  2009-02-07  4:27 ` [ruby-core:21905] [Bug #806] " Jeremy Kemper
@ 2009-03-03 11:37 ` Matthew Ford
  3 siblings, 0 replies; 5+ messages in thread
From: Matthew Ford @ 2009-03-03 11:37 UTC (permalink / raw
  To: ruby-core

Issue #806 has been updated by Matthew Ford.


I can confirm that  Jeremy Kemper's patch works for me and that the patch that was applied breaks IO that doesn't respond to read_nonblock.
----------------------------------------
http://redmine.ruby-lang.org/issues/show/806

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-03-03 11:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-01 18:22 [ruby-core:20191] [Bug #806] Net::Protocol#rbuf_fill is slow Aaron Patterson
2008-12-02  6:28 ` [ruby-core:20198] " Yukihiro Matsumoto
2008-12-02  6:31 ` [ruby-core:20199] [Bug #806](Closed) " Yukihiro Matsumoto
2009-02-07  4:27 ` [ruby-core:21905] [Bug #806] " Jeremy Kemper
2009-03-03 11:37 ` [ruby-core:22642] " Matthew Ford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).