From: Aaron Patterson Date: 2011-11-09T01:06:18+09:00 Subject: [ruby-core:40848] Re: [Ruby 1.9 - Bug #5138][Open] Add nonblocking IO that does not use exceptions for EOF and EWOULDBLOCK --W/nzBZO5zC0uMSeA Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Nov 08, 2011 at 06:59:38AM +0900, Eric Wong wrote: > Yehuda Katz wrote: > > Bug #5138: Add nonblocking IO that does not use exceptions for EOF and = EWOULDBLOCK >=20 > I don't want this issue to get dropped, so I'm summarizing the > discussion so far for the benefit of folks who haven't followed > everything (including discussions in related threads to this one). >=20 > * readpartial + IO.select can still block indefinitely due to: >=20 > - user space layers and buffering (SSL, gzip/zlib) >=20 > - spurious wakeup on some socket types/kernels >=20 > * Exceptions with the current *_nonblock methods are expensive. >=20 > - extending with IO::Wait* increments the global VM state version >=20 > * This invalidates both the global method cache and inline caches in > 1.9.3. Invaliding the caches is itself an inexpensive operation > since 1.9.3, but the cost of subsequent cache misses can hurt[1] >=20 > * This can overflow VM state version within a couple of hours/days > on 32-bit systems if IO::Wait* exceptions are raised constantly. > Overflowing state version may trigger very rare bugs with > false-positive cache hits; vm_clear_all_inline_method_cache() is > currently unimplemented to deal with this situation. > Overflow is not likely to ever be a problem on 64-bit. >=20 > - backtrace generation cost >=20 > * Generating backtrace is more expensive in MRI 1.9/2.x than MRI 1.8, > it might be even more expensive in alternative VMs >=20 > * Additional garbage overhead from backtrace strings >=20 > * IO::Wait*/Errno::EAGAIN are very common exceptions. >=20 > - Anybody using *_nonblock will need to care for exceptions with a > begin/rescue. Changing begin/rescue into the equivalent > case statement requires roughly the same amount of code. >=20 > - These exceptions make $DEBUG unnecessarily noisy I spoke with matz about this issue at RubyConf. I *think* he said it was a good feature, but he wanted a different API. I can't remember exactly. Maybe matz can comment? --=20 Aaron Patterson http://tenderlovemaking.com/ --W/nzBZO5zC0uMSeA Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) iQEcBAEBAgAGBQJOuVNrAAoJEJUxcLy0/6/GwXwH/jtI44+NNQneaWuqC0SKBiMd D34Xbcg4Iyi8OQp4m/nS7CbCvLFc1PwAhUcARmiw1kYKUP4uUHaLndgNPaIbRMje hhYHqeocJx/NkVQKECmLGjk/sVQ9WNFo9CzM3dmws7srFhQU9FthI3cu0xsWC4Gg 7n1VilHq2MJpOIzbr4GLnhyrJl63hhd1dkTvbU13+2il7hVWhO1ryEfwq5MircwD hCVTuvlfSIOk1RLewtTIfXRw7IoYPIxlI3K5AhQI6AZNGHzOc2lt9P0crOxFQz1A AG6yE44UkIkp45jmqFPjhzx+g5ZiaEGIdQmfhOSQ/buupAUm3+ceDM0Z1K/19vs= =3SOe -----END PGP SIGNATURE----- --W/nzBZO5zC0uMSeA--