From: Eric Wong Date: 2011-04-11T08:52:13+09:00 Subject: [ruby-core:35694] Re: [Ruby 1.9 - Feature #4560] [PATCH] lib/net/protocol.rb: avoid exceptions in rbuf_fill redmine@ruby-lang.org wrote: > On JRuby master, I've made a change that does not generate backtraces > for EAGAIN, to avoid the overhead of generating it for the expected > case of read_nonblock having nothing available. But it's a bit of a > band-aid. The overhead from even *creating* an exception can be weigh > into a tight loop over read_nonblock when there's nothing available, > and of course having the backtrace disabled could annoy someone if it > leaked out (JRuby points them to a flag to turn the backtraces on). > Not sure what's the best long-term solution. Perhaps something similar to the kgio[1] API with IO#tryread/trywrite (that return :wait_readable/:wait_writable Symbols) can be moved into the core Ruby IO class (and deprecate IO#read_nonblock/write_nonblock). > Also, the 1.9 practice of mixing in WaitReadable is really dreadful. > It's bad enough in JRuby that it has to construct a new singleton > class for every raised exception, but the cache effects in 1.9 are > really painful. Yes, I've been trying to fix that in trunk, too: [ruby-core:35672] [1] http://bogomips.org/kgio - *nix-only, but the API is fully RDoc-ed -- Eric Wong