[#35446] [Ruby 1.9 - Bug #4477][Open] Kernel:exec and backtick (`) don't work for certain system commands — Joachim Wuttke <j.wuttke@...>

10 messages 2011/03/07

[#35476] [Ruby 1.9 - Bug #4489][Open] [PATCH] Encodings with /-(unix|dos|mac)\Z/ — "James M. Lawrence" <quixoticsycophant@...>

20 messages 2011/03/10

[#35552] [Ruby 1.9 - Feature #4523][Open] Kernel#require to return the path of the loaded file — Alex Young <alex@...>

14 messages 2011/03/24

[#35565] [Ruby 1.9 - Feature #4531][Open] [PATCH 0/7] use poll() instead of select() in certain cases — Eric Wong <normalperson@...>

33 messages 2011/03/28

[#35566] [Ruby 1.9 - Feature #4532][Open] [PATCH] add IO#pread and IO#pwrite methods — Eric Wong <normalperson@...>

12 messages 2011/03/28

[#35586] [Ruby 1.9 - Feature #4538][Open] [PATCH (cleanup)] avoid unnecessary select() calls before doing I/O — Eric Wong <normalperson@...>

9 messages 2011/03/29

[ruby-core:35585] Re: [Ruby 1.9 - Feature #4531][Open] [PATCH 0/7] use poll() instead of select() in certain cases

From: Eric Wong <normalperson@...>
Date: 2011-03-29 18:11:57 UTC
List: ruby-core #35585
KOSAKI Motohiro <kosaki.motohiro@gmail.com> wrote:
<snip>
Thanks again for your reply and support :>

> 2011/3/29 Eric Wong <normalperson@yhbt.net>:
> > I mainly think select() is a horrible interface and having extension
> > authors to deal with HAVE_RB_FD_INIT and remembering rb_fd_term() is
> > dangerous.  Small bits of pressure from Rubyists can hopefully steer
> > other OSes towards better poll() support.
> 
> I'm sorry. I haven't catch this. can you please explain more detail?

rb_fd_init() uses malloc() to create fdsets instead of traditional stack
allocation.  This also requires using rb_fd_term() to free() memory, so
rb_ensure() must be used[1].   Often this is for waiting on a single fd,
so the rb_io_poll_fd() interface is better for extension authors all
around even if it internally uses select().

As for poll() support, Evan Phoenix pointed out poll() doesn't work on
OS X with ttys/pipes (ref: [ruby-core:35529]).  I don't know about other
kernels.  Ideally, poll() should work everywhere select() does (and
select() should be deprecated).  I would like to encourage other OSes to
get where Linux is (or get more people using Linux :).

On a related note:

  Ruby also still needlessly checks for read/writability with select()[2]
  even though though we have support for blocking regions.   I think
  that is safe to remove if we check return values with
  rb_io_wait_{read,writ}able().  One part of
  http://redmine.ruby-lang.org/issues/4535 does exactly this but I have
  another patch to kill more unnecessary select() calls that aren't
  bugs, just extra code/syscalls.


[1] though from reading through do_select() in thread.c, I don't think
do_select() can raise..

[2] via rb_thread_wait_fd()/rb_thread_fd_writable()

-- 
Eric Wong

In This Thread