Project

General

Profile

Actions

Feature #4531

closed

[PATCH 0/7] use poll() instead of select() in certain cases

Added by normalperson (Eric Wong) over 13 years ago. Updated over 13 years ago.

Status:
Closed
Target version:
[ruby-core:35565]

Description

=begin
ref: [ruby-core:35527]

This adds a new C API function with the following prototype:

rb_io_poll_fd(int fd, short events, int timeout);

It is emulated using select() for platforms that we do not support
poll() for. It is much easier to use than rb_thread_select() and
rb_thread_fd_select() for the common case in C extensions[1].

For Linux (and eventually any other platforms where poll() works for all
select()-able files), we actually implement rb_io_poll_fd() using the
poll() system call which means it is faster for high numbered file
descriptors and does not put malloc pressure on the garbage collector.

Lastly, since IO.select() is commonly used with a single IO object
in my experience, we will try to use rb_io_poll_fd() in that case.

There is also a new testcase for io/wait since I needed to verify my
changes to ext/io/wait.c were correct.

No failures were introduced to test-all and test-rubyspec targets with
either the select() or poll()-based implementation of rb_io_poll_fd()
on my platform (Linux x86_64)

[1] see patches for changes I made in ext/socket/init.c, ext/io/wait.c,
and ext/readline/readline.c:
$ git diff --stat origin/trunk -- ext
ext/io/wait/wait.c | 34 +++-------------------
ext/readline/readline.c | 6 +---
ext/socket/init.c | 72 ++++++++---------------------------------------
3 files changed, 18 insertions(+), 94 deletions(-)

=end


Files

poll.mbox (19.9 KB) poll.mbox mbox containing all patches `git am poll.mbox` normalperson (Eric Wong), 03/28/2011 11:48 AM
io_select_using_poll_test.rb (366 Bytes) io_select_using_poll_test.rb contrived test case normalperson (Eric Wong), 03/29/2011 01:59 AM
rb_wait_for_single_fd.mbox (18.1 KB) rb_wait_for_single_fd.mbox normalperson (Eric Wong), 05/03/2011 07:45 AM
rb_wait_for_single_fd-followup.mbox (9.25 KB) rb_wait_for_single_fd-followup.mbox normalperson (Eric Wong), 05/04/2011 11:45 AM
0001-rb_wait_for_single_fd-use-ppoll-instead-of-poll.patch (4.2 KB) 0001-rb_wait_for_single_fd-use-ppoll-instead-of-poll.patch normalperson (Eric Wong), 05/05/2011 06:36 AM
0001-add-io-wait-benchmarks.patch (1.27 KB) 0001-add-io-wait-benchmarks.patch normalperson (Eric Wong), 05/05/2011 06:53 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0