https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112011-04-11T07:46:40ZRuby Issue Tracking SystemRuby master - Feature #4560: [PATCH] lib/net/protocol.rb: avoid exceptions in rbuf_fillhttps://redmine.ruby-lang.org/issues/4560?journal_id=163482011-04-11T07:46:40Zheadius (Charles Nutter)headius@headius.com
<ul></ul><p>=begin<br>
This is an interesting one. JRuby recently changed how we generate backtraces to using the Java backtrace as the master. This means our backtraces are as expensive to generate as a full Java backtrace for the full stack (think generating a backtrace for all Ruby and C and intermediate calls in Ruby). As a result, any algorithms that generate backtraces as part of normal flow control took a big perf hit.</p>
<p>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 <em>creating</em> 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.</p>
<p>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.<br>
=end</p> Ruby master - Feature #4560: [PATCH] lib/net/protocol.rb: avoid exceptions in rbuf_fillhttps://redmine.ruby-lang.org/issues/4560?journal_id=163492011-04-11T09:23:06Znormalperson (Eric Wong)normalperson@yhbt.net
<ul></ul><p>=begin<br>
<a href="mailto:redmine@ruby-lang.org" class="email">redmine@ruby-lang.org</a> wrote:</p>
<blockquote>
<p>On JRuby master, I've made a change that does not generate backtraces<br>
for EAGAIN, to avoid the overhead of generating it for the expected<br>
case of read_nonblock having nothing available. But it's a bit of a<br>
band-aid. The overhead from even <em>creating</em> an exception can be weigh<br>
into a tight loop over read_nonblock when there's nothing available,<br>
and of course having the backtrace disabled could annoy someone if it<br>
leaked out (JRuby points them to a flag to turn the backtraces on).<br>
Not sure what's the best long-term solution.</p>
</blockquote>
<p>Perhaps something similar to the kgio[1] API with IO#tryread/trywrite<br>
(that return :wait_readable/:wait_writable Symbols) can be moved into<br>
the core Ruby IO class (and deprecate IO#read_nonblock/write_nonblock).</p>
<blockquote>
<p>Also, the 1.9 practice of mixing in WaitReadable is really dreadful.<br>
It's bad enough in JRuby that it has to construct a new singleton<br>
class for every raised exception, but the cache effects in 1.9 are<br>
really painful.</p>
</blockquote>
<p>Yes, I've been trying to fix that in trunk, too: <a href="/issues/4289">[ruby-core:35672]</a></p>
<p>[1] <a href="http://bogomips.org/kgio" class="external">http://bogomips.org/kgio</a> - *nix-only, but the API is fully RDoc-ed</p>
<p>--<br>
Eric Wong<br>
=end</p> Ruby master - Feature #4560: [PATCH] lib/net/protocol.rb: avoid exceptions in rbuf_fillhttps://redmine.ruby-lang.org/issues/4560?journal_id=251142012-03-25T15:16:06Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Assigned</i></li><li><strong>Assignee</strong> set to <i>akr (Akira Tanaka)</i></li></ul> Ruby master - Feature #4560: [PATCH] lib/net/protocol.rb: avoid exceptions in rbuf_fillhttps://redmine.ruby-lang.org/issues/4560?journal_id=318872012-10-28T23:12:28Zakr (Akira Tanaka)akr@fsij.org
<ul><li><strong>Target version</strong> changed from <i>2.0.0</i> to <i>2.6</i></li></ul> Ruby master - Feature #4560: [PATCH] lib/net/protocol.rb: avoid exceptions in rbuf_fillhttps://redmine.ruby-lang.org/issues/4560?journal_id=686812017-12-25T18:14:59Znaruse (Yui NARUSE)naruse@airemix.jp
<ul><li><strong>Target version</strong> deleted (<del><i>2.6</i></del>)</li></ul> Ruby master - Feature #4560: [PATCH] lib/net/protocol.rb: avoid exceptions in rbuf_fillhttps://redmine.ruby-lang.org/issues/4560?journal_id=709002018-03-08T09:09:55Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Assignee</strong> changed from <i>akr (Akira Tanaka)</i> to <i>normalperson (Eric Wong)</i></li></ul><p><a class="user active user-mention" href="https://redmine.ruby-lang.org/users/724">@normalperson (Eric Wong)</a>, I think that this issue has been fixed more elegantly by introducing <code>read_nonblock(exception: false)</code>. Am I right?</p> Ruby master - Feature #4560: [PATCH] lib/net/protocol.rb: avoid exceptions in rbuf_fillhttps://redmine.ruby-lang.org/issues/4560?journal_id=940912021-10-08T20:55:36Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li></ul>