From: Charles Nutter <headius@headius.com>
To: ruby-core@ruby-lang.org
Subject: [ruby-core:42743] [ruby-trunk - Feature #5138] Add nonblocking IO that does not use exceptions for EOF and EWOULDBLOCK
Date: Mon, 20 Feb 2012 04:41:15 +0900 [thread overview]
Message-ID: <redmine.journal-23973.20120220044114@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-5138.20110802073514@ruby-lang.org
Issue #5138 has been updated by Charles Nutter.
I never got to weigh in on this thread back in the day, and I'm working on IO stuff more recently, so a few thoughts...
Eric Wong wrote:
> * Exceptions with the current *_nonblock methods are expensive.
>
> - extending with IO::Wait* increments the global VM state version
This is really poor form. I'm not sure why it hasn't been fixed yet. JRuby master solves this in a neat, compatible way: instead of raising singleton EAGAIN with WaitReable or WaitWritable mixed in, we raise EAGAINReadable or EAGAINWritable, subclasses that have already done the mixing. No other changes are needed.
> - backtrace generation cost
In JRuby, EAGAIN does not generate a backtrace unless you pass a flag, since generally it's an "expected" exception and you don't want the backtrace anyway.
How does this translate to perf?
system ~/projects $ jruby eagain_bench.rb
1.553000 0.000000 1.553000 ( 1.553000)
0.673000 0.000000 0.673000 ( 0.673000)
0.667000 0.000000 0.667000 ( 0.667000)
0.669000 0.000000 0.669000 ( 0.669000)
0.696000 0.000000 0.696000 ( 0.697000)
system ~/projects $ rvm 1.9.3 do ruby eagain_bench.rb
1.250000 0.150000 1.400000 ( 1.396295)
1.250000 0.150000 1.400000 ( 1.408975)
1.260000 0.150000 1.410000 ( 1.405947)
1.250000 0.150000 1.400000 ( 1.405391)
1.260000 0.150000 1.410000 ( 1.407389)
system ~/projects $ rvm ruby-head do ruby eagain_bench.rb
1.310000 0.120000 1.430000 ( 1.428627)
1.300000 0.120000 1.420000 ( 1.430652)
1.310000 0.130000 1.440000 ( 1.426011)
1.310000 0.120000 1.430000 ( 1.430642)
1.310000 0.120000 1.430000 ( 1.436441)
Rather well, I think.
----------------------------------------
Feature #5138: Add nonblocking IO that does not use exceptions for EOF and EWOULDBLOCK
https://bugs.ruby-lang.org/issues/5138
Author: Yehuda Katz
Status: Open
Priority: Normal
Assignee: Yukihiro Matsumoto
Category: core
Target version: 1.9.4
The current Ruby I/O classes have non-blocking methods (read_nonblock and write_nonblock). These methods will never block, and if they would block, they raise an exception instead (IO::WaitReadable or IO::WaitWritable). In addition, if the IO is at EOF, they raise an EOFError.
These exceptions are raised repeatedly in virtually every use of the non-blocking methods. This patch adds a pair of methods (try_read_nonblock and try_write_nonblock) that have the same semantics as the existing methods, but they return Symbols instead of raising exceptions for these routine cases:
* :read_would_block
* :write_would_block
* :eof
The patch contains updates for IO, StringIO, and OpenSSL. The updates are fully documented and tested.
--
http://bugs.ruby-lang.org/
next prev parent reply other threads:[~2012-02-19 19:57 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-01 22:35 [ruby-core:38666] [Ruby 1.9 - Bug #5138][Open] Add nonblocking IO that does not use exceptions for EOF and EWOULDBLOCK Yehuda Katz
2011-08-01 22:46 ` [ruby-core:38667] " Aaron Patterson
2011-08-01 23:06 ` [ruby-core:38669] " Urabe Shyouhei
2011-08-01 23:14 ` [ruby-core:38671] " Eric Wong
2011-08-01 23:30 ` [ruby-core:38674] " Urabe Shyouhei
2011-08-01 23:35 ` [ruby-core:38675] " Eric Wong
2011-08-01 23:42 ` [ruby-core:38676] " Urabe Shyouhei
2011-08-01 23:48 ` [ruby-core:38677] " Eric Wong
2011-08-02 0:08 ` [ruby-core:38679] " Urabe Shyouhei
2011-08-02 0:26 ` [ruby-core:38682] " Eric Wong
2011-08-02 0:24 ` [ruby-core:38681] " Tanaka Akira
2011-08-02 5:19 ` [ruby-core:38692] " Tanaka Akira
2011-08-03 2:20 ` [ruby-core:38733] " Eric Wong
2011-08-04 4:16 ` [ruby-core:38771] " KOSAKI Motohiro
2011-08-06 10:09 ` [ruby-core:38824] " Tanaka Akira
2011-08-07 9:53 ` [ruby-core:38830] " KOSAKI Motohiro
2011-08-01 22:49 ` [ruby-core:38668] [Ruby 1.9 - Bug #5138] " Shyouhei Urabe
2011-08-01 23:19 ` [ruby-core:38673] " Yehuda Katz
2011-08-30 0:49 ` [ruby-core:39191] " Eric Wong
2011-08-01 23:07 ` [ruby-core:38670] Re: [Ruby 1.9 - Bug #5138][Open] " Eric Wong
2011-08-01 23:16 ` [ruby-core:38672] " Yehuda Katz
2011-08-02 0:08 ` [ruby-core:38680] " Eric Wong
2011-08-02 0:27 ` [ruby-core:38683] " Yehuda Katz
2011-08-02 0:02 ` [ruby-core:38678] [Ruby 1.9 - Bug #5138] " Yehuda Katz
2011-08-02 4:01 ` [ruby-core:38691] [Ruby 1.9 - Feature " Yehuda Katz
2011-08-02 8:48 ` [ruby-core:38702] " Alex Young
2011-08-03 14:03 ` [ruby-core:38745] Re: [Ruby 1.9 - Bug #5138][Open] " Tanaka Akira
2011-08-03 17:54 ` [ruby-core:38762] " Aaron Patterson
2011-08-03 20:22 ` [ruby-core:38767] " Tanaka Akira
2011-11-07 21:59 ` [ruby-core:40821] " Eric Wong
2011-11-08 16:06 ` [ruby-core:40848] " Aaron Patterson
2011-11-09 23:00 ` [ruby-core:40895] " Eric Wong
2011-11-20 5:05 ` [ruby-core:41165] " Aaron Patterson
2011-11-20 6:30 ` [ruby-core:41167] " KOSAKI Motohiro
2011-12-15 0:12 ` [ruby-core:41660] " Eric Wong
2012-02-19 19:41 ` Charles Nutter [this message]
2012-02-19 20:19 ` [ruby-core:42744] [ruby-trunk - Feature #5138] " Charles Nutter
2012-03-16 4:06 ` [ruby-core:43327] " Charles Nutter
2012-06-30 15:55 ` [ruby-core:45993] " tenderlovemaking (Aaron Patterson)
2012-06-30 16:29 ` [ruby-core:45998] " rosenfeld (Rodrigo Rosenfeld Rosas)
2012-06-30 17:47 ` [ruby-core:46002] " drbrain (Eric Hodel)
2012-06-30 19:30 ` [ruby-core:46006] " Aaron Patterson
2012-06-30 19:34 ` [ruby-core:46007] " tenderlovemaking (Aaron Patterson)
2012-06-30 19:51 ` [ruby-core:46012] " rosenfeld (Rodrigo Rosenfeld Rosas)
2012-07-01 16:58 ` [ruby-core:46064] " mame (Yusuke Endoh)
2012-07-23 12:54 ` [ruby-core:46646] " mame (Yusuke Endoh)
2013-04-23 20:25 ` [ruby-core:54531] " headius (Charles Nutter)
2013-04-23 21:19 ` [ruby-core:54533] " headius (Charles Nutter)
2013-07-09 21:24 ` [ruby-core:55884] " tenderlovemaking (Aaron Patterson)
2013-07-10 0:03 ` [ruby-core:55890] " Eric Wong
2013-07-10 0:52 ` [ruby-core:55892] " Aaron Patterson
2013-07-10 1:52 ` [ruby-core:55895] " Eric Wong
2013-07-11 17:15 ` [ruby-core:55954] " Aaron Patterson
2013-07-11 18:55 ` [ruby-core:55956] " Eric Wong
2013-07-11 20:55 ` [ruby-core:55957] " Aaron Patterson
2013-07-10 0:12 ` [ruby-core:55891] " tenderlovemaking (Aaron Patterson)
2013-07-26 7:52 ` [ruby-core:56196] Re: [Ruby 1.9 - Bug #5138][Open] " Aaron Patterson
2013-07-26 23:14 ` [ruby-core:56208] " Eric Wong
2013-07-27 4:36 ` [ruby-core:56213] [ruby-trunk - Feature #5138] " matz (Yukihiro Matsumoto)
2013-09-27 11:14 ` [ruby-core:57433] " headius (Charles Nutter)
2014-05-30 5:53 ` [ruby-core:62850] " headius
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-23973.20120220044114@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).