https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112011-03-28T21:23:14ZRuby Issue Tracking SystemRuby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=162272011-03-28T21:23:14Zkosaki (Motohiro KOSAKI)kosaki.motohiro@gmail.com
<ul></ul><p>=begin</p>
<blockquote>
<p>ref: <a href="https://blade.ruby-lang.org/ruby-core/35527">[ruby-core:35527]</a></p>
<p>This adds a new C API function with the following prototype:</p>
<p>Â rb_io_poll_fd(int fd, short events, int timeout);</p>
<p>It is emulated using select() for platforms that we do not support<br>
poll() for. Â It is much easier to use than rb_thread_select() and<br>
rb_thread_fd_select() for the common case in C extensions[1].</p>
<p>For Linux (and eventually any other platforms where poll() works for all<br>
select()-able files), we actually implement rb_io_poll_fd() using the<br>
poll() system call which means it is faster for high numbered file<br>
descriptors and does not put malloc pressure on the garbage collector.</p>
</blockquote>
<p>Meta review comment. All performance patches should have mesured<br>
performance number.</p>
<p>And, if you really want to care C10K scalability issue, why don't you use<br>
epoll?</p>
<blockquote>
<p>Lastly, since IO.select() is commonly used with a single IO object<br>
in my experience, we will try to use rb_io_poll_fd() in that case.</p>
<p>There is also a new testcase for io/wait since I needed to verify my<br>
changes to ext/io/wait.c were correct.</p>
<p>No failures were introduced to test-all and test-rubyspec targets with<br>
either the select() or poll()-based implementation of rb_io_poll_fd()<br>
on my platform (Linux x86_64)<br>
=end</p>
</blockquote> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=162292011-03-29T01:59:36Znormalperson (Eric Wong)normalperson@yhbt.net
<ul><li><strong>File</strong> <a href="/attachments/1562">io_select_using_poll_test.rb</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/1562/io_select_using_poll_test.rb">io_select_using_poll_test.rb</a> added</li></ul><p>=begin<br>
Added a contrived test case, using a high RLIMIT_NOFILE (e.g. ulimit -n 16384) is recommended to make the results more apparent.<br>
=end</p> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=162302011-03-29T02:23:06Znormalperson (Eric Wong)normalperson@yhbt.net
<ul></ul><p>=begin<br>
KOSAKI Motohiro <a href="mailto:kosaki.motohiro@gmail.com" class="email">kosaki.motohiro@gmail.com</a> wrote:</p>
<blockquote>
<blockquote>
<p>ref: <a href="https://blade.ruby-lang.org/ruby-core/35527">[ruby-core:35527]</a></p>
<p>This adds a new C API function with the following prototype:</p>
<p> rb_io_poll_fd(int fd, short events, int timeout);</p>
<p>It is emulated using select() for platforms that we do not support<br>
poll() for. It is much easier to use than rb_thread_select() and<br>
rb_thread_fd_select() for the common case in C extensions[1].</p>
<p>For Linux (and eventually any other platforms where poll() works for all<br>
select()-able files), we actually implement rb_io_poll_fd() using the<br>
poll() system call which means it is faster for high numbered file<br>
descriptors and does not put malloc pressure on the garbage collector.</p>
</blockquote>
<p>Meta review comment. All performance patches should have mesured<br>
performance number.</p>
</blockquote>
<p>Based on a contrived test case:<br>
<a href="http://redmine.ruby-lang.org/attachments/1562/io_select_using_poll_test.rb" class="external">http://redmine.ruby-lang.org/attachments/1562/io_select_using_poll_test.rb</a><br>
I get the following results:</p>
<p>---- before NOFILE=1024 ---<br>
max fd: 1024 (results not apparent with <= 1024 max fd)<br>
last IO: #<IO:fd 1022><br>
2.050000 1.440000 3.490000 ( 3.476264)</p>
<p>GC.count: 386</p>
<p>---- after NOFILE=1024 ---<br>
max fd: 1024 (results not apparent with <= 1024 max fd)<br>
last IO: #<IO:fd 1022><br>
2.430000 0.320000 2.750000 ( 2.734643)</p>
<p>GC.count: 343</p>
<p>---- before NOFILE=16384 ---<br>
max fd: 16384 (results not apparent with <= 1024 max fd)<br>
last IO: #<IO:fd 16382><br>
3.610000 5.680000 9.290000 ( 9.266017)</p>
<p>GC.count: 643</p>
<p>---- after NOFILE=16384 ---<br>
max fd: 16384 (results not apparent with <= 1024 max fd)<br>
last IO: #<IO:fd 16382><br>
2.970000 0.450000 3.420000 ( 3.415426)</p>
<p>GC.count: 394</p>
<p>I don't have real world results/test case but I think small bits<br>
like this count for the future.</p>
<blockquote>
<p>And, if you really want to care C10K scalability issue, why don't you use<br>
epoll?</p>
</blockquote>
<p>I assume you mean Ruby programming in general and not making MRI itself<br>
use epoll().</p>
<p>I find synchronous programming easier especially when dealing with<br>
existing libraries (I use Ruby to make programming life easier :)</p>
<p>For me, thousands of native threads (NPTL + 64-bit) often makes more<br>
sense than epoll() + non-blocking I/O.</p>
<p>Concurrent connections isn't always an issue, either, but also sometimes<br>
have many open file handles to support other tasks[1].</p>
<p>I mainly think select() is a horrible interface and having extension<br>
authors to deal with HAVE_RB_FD_INIT and remembering rb_fd_term() is<br>
dangerous. Small bits of pressure from Rubyists can hopefully steer<br>
other OSes towards better poll() support.</p>
<p>Thank you for your time!</p>
<p>[1] DB connection pool, large memcached pool, regular files,<br>
various message queues, etc...</p>
<p>--<br>
Eric Wong<br>
=end</p> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=162422011-03-29T21:07:37Zkosaki (Motohiro KOSAKI)kosaki.motohiro@gmail.com
<ul><li><strong>Assignee</strong> set to <i>kosaki (Motohiro KOSAKI)</i></li></ul><p>=begin</p>
<p>=end</p> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=162442011-03-29T21:23:06Zkosaki (Motohiro KOSAKI)kosaki.motohiro@gmail.com
<ul></ul><p>=begin<br>
2011/3/29 Eric Wong <a href="mailto:normalperson@yhbt.net" class="email">normalperson@yhbt.net</a>:</p>
<blockquote>
<p>KOSAKI Motohiro <a href="mailto:kosaki.motohiro@gmail.com" class="email">kosaki.motohiro@gmail.com</a> wrote:</p>
<blockquote>
<blockquote>
<p>ref: <a href="https://blade.ruby-lang.org/ruby-core/35527">[ruby-core:35527]</a></p>
<p>This adds a new C API function with the following prototype:</p>
<p>Â rb_io_poll_fd(int fd, short events, int timeout);</p>
<p>It is emulated using select() for platforms that we do not support<br>
poll() for. Â It is much easier to use than rb_thread_select() and<br>
rb_thread_fd_select() for the common case in C extensions[1].</p>
<p>For Linux (and eventually any other platforms where poll() works for all<br>
select()-able files), we actually implement rb_io_poll_fd() using the<br>
poll() system call which means it is faster for high numbered file<br>
descriptors and does not put malloc pressure on the garbage collector.</p>
</blockquote>
<p>Meta review comment. All performance patches should have mesured<br>
performance number.</p>
</blockquote>
<p>Based on a contrived test case:<br>
 <a href="http://redmine.ruby-lang.org/attachments/1562/io_select_using_poll_test.rb" class="external">http://redmine.ruby-lang.org/attachments/1562/io_select_using_poll_test.rb</a><br>
I get the following results:</p>
<p>---- before NOFILE24 ---<br>
max fd: 1024 (results not apparent with <<br>
=end</p>
</blockquote> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=162472011-03-30T03:23:06Znormalperson (Eric Wong)normalperson@yhbt.net
<ul></ul><p>=begin<br>
KOSAKI Motohiro <a href="mailto:kosaki.motohiro@gmail.com" class="email">kosaki.motohiro@gmail.com</a> wrote:<br>
<br>
Thanks again for your reply and support :></p>
<blockquote>
<p>2011/3/29 Eric Wong <a href="mailto:normalperson@yhbt.net" class="email">normalperson@yhbt.net</a>:</p>
<blockquote>
<p>I mainly think select() is a horrible interface and having extension<br>
authors to deal with HAVE_RB_FD_INIT and remembering rb_fd_term() is<br>
dangerous. Small bits of pressure from Rubyists can hopefully steer<br>
other OSes towards better poll() support.</p>
</blockquote>
<p>I'm sorry. I haven't catch this. can you please explain more detail?</p>
</blockquote>
<p>rb_fd_init() uses malloc() to create fdsets instead of traditional stack<br>
allocation. This also requires using rb_fd_term() to free() memory, so<br>
rb_ensure() must be used[1]. Often this is for waiting on a single fd,<br>
so the rb_io_poll_fd() interface is better for extension authors all<br>
around even if it internally uses select().</p>
<p>As for poll() support, Evan Phoenix pointed out poll() doesn't work on<br>
OS X with ttys/pipes (ref: <a href="https://blade.ruby-lang.org/ruby-core/35529">[ruby-core:35529]</a>). I don't know about other<br>
kernels. Ideally, poll() should work everywhere select() does (and<br>
select() should be deprecated). I would like to encourage other OSes to<br>
get where Linux is (or get more people using Linux :).</p>
<p>On a related note:</p>
<p>Ruby also still needlessly checks for read/writability with select()[2]<br>
even though though we have support for blocking regions. I think<br>
that is safe to remove if we check return values with<br>
rb_io_wait_{read,writ}able(). One part of<br>
<a href="http://redmine.ruby-lang.org/issues/4535" class="external">http://redmine.ruby-lang.org/issues/4535</a> does exactly this but I have<br>
another patch to kill more unnecessary select() calls that aren't<br>
bugs, just extra code/syscalls.</p>
<p>[1] though from reading through do_select() in thread.c, I don't think<br>
do_select() can raise..</p>
<p>[2] via rb_thread_wait_fd()/rb_thread_fd_writable()</p>
<p>--<br>
Eric Wong<br>
=end</p> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=162482011-03-30T03:29:06Znormalperson (Eric Wong)normalperson@yhbt.net
<ul></ul><p>=begin<br>
Eric Wong <a href="mailto:normalperson@yhbt.net" class="email">normalperson@yhbt.net</a> wrote:</p>
<blockquote>
<p>On a related note:</p>
<p>Ruby also still needlessly checks for read/writability with select()[2]<br>
even though though we have support for blocking regions. I think<br>
that is safe to remove if we check return values with<br>
rb_io_wait_{read,writ}able(). One part of<br>
<a href="http://redmine.ruby-lang.org/issues/4535" class="external">http://redmine.ruby-lang.org/issues/4535</a> does exactly this but I have<br>
another patch to kill more unnecessary select() calls that aren't<br>
bugs, just extra code/syscalls.</p>
</blockquote>
<p>Just opened this one: <a href="http://redmine.ruby-lang.org/issues/4538" class="external">http://redmine.ruby-lang.org/issues/4538</a></p>
<p>--<br>
Eric Wong<br>
=end</p> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=167202011-04-30T03:46:47Zkosaki (Motohiro KOSAKI)kosaki.motohiro@gmail.com
<ul></ul><p>=begin<br>
commnet for patch 0001.</p>
<p>begin<br>
require 'io/wait'<br>
rescue LoadError<br>
end</p>
<p>shold be</p>
<p>begin<br>
require 'io/wait'<br>
rescue LoadError</p>
<a name="skip-this-test"></a>
<h1 >skip this test.<a href="#skip-this-test" class="wiki-anchor">¶</a></h1>
<p>return<br>
end</p>
<p>If we can't load io/wait, why do we need to run the tests for it?<br>
Anyway, I'll commit it.<br>
=end</p> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=167222011-04-30T08:23:08Znormalperson (Eric Wong)normalperson@yhbt.net
<ul></ul><p>=begin<br>
Motohiro KOSAKI <a href="mailto:kosaki.motohiro@gmail.com" class="email">kosaki.motohiro@gmail.com</a> wrote:</p>
<blockquote>
<p>Issue <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: [PATCH 0/7] use poll() instead of select() in certain cases (Closed)" href="https://redmine.ruby-lang.org/issues/4531">#4531</a> has been updated by Motohiro KOSAKI.</p>
<p>commnet for patch 0001.</p>
<p>begin<br>
require 'io/wait'<br>
rescue LoadError<br>
end</p>
<p>shold be</p>
<p>begin<br>
require 'io/wait'<br>
rescue LoadError</p>
<a name="skip-this-test"></a>
<h1 >skip this test.<a href="#skip-this-test" class="wiki-anchor">¶</a></h1>
<p>return<br>
end</p>
<p>If we can't load io/wait, why do we need to run the tests for it?<br>
Anyway, I'll commit it.</p>
</blockquote>
<p>I used a condition at the end of the class definition:</p>
<p>end if IO.method_defined?(:wait)</p>
<p>I copied the style from test/io/nonblock/test_flush.rb</p>
<p>--<br>
Eric Wong<br>
=end</p> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=167272011-04-30T16:22:07Zkosaki (Motohiro KOSAKI)kosaki.motohiro@gmail.com
<ul></ul><p>=begin<br>
I also commited io_select_using_poll_test.rb (but modified a little) at r31390.<br>
=end</p> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=167312011-05-01T02:23:09Znormalperson (Eric Wong)normalperson@yhbt.net
<ul></ul><p>KOSAKI Motohiro <a href="mailto:kosaki.motohiro@gmail.com" class="email">kosaki.motohiro@gmail.com</a> wrote:</p>
<blockquote>
<p>I'd suggest to make generic single fd waiting abstract function, like below.<br>
rb_wait_for_single_fd(int fd, int events, struct timeval *tv);</p>
<p>Also, RB_POLLIN should be avoided.</p>
</blockquote>
<p>Huh? What would I use for events instead?</p>
<p>Thanks for taking your time to review this!</p>
<p>--<br>
Eric Wong</p> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=167322011-05-01T12:23:07Zkosaki (Motohiro KOSAKI)kosaki.motohiro@gmail.com
<ul></ul><blockquote>
<blockquote>
<p>Also, RB_POLLIN should be avoided.</p>
</blockquote>
<p>Huh? What would I use for events instead?</p>
<p>Thanks for taking your time to review this!</p>
</blockquote>
<p>I meant RB_POLLIN is not backend independ name.</p>
<p>thanks.</p> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=167452011-05-03T07:45:48Znormalperson (Eric Wong)normalperson@yhbt.net
<ul><li><strong>File</strong> <a href="/attachments/1627">rb_wait_for_single_fd.mbox</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/1627/rb_wait_for_single_fd.mbox">rb_wait_for_single_fd.mbox</a> added</li></ul><p>I've updated the series with your suggestions and rebased against trunk r31412 and uploaded a new<br>
mbox with the 6 following patches:</p>
<ol>
<li>rb_wait_for_single_fd: initial implementation</li>
<li>io/wait: switch to rb_wait_for_single_fd()</li>
<li>ext/socket/init.c: simplify wait_connectable() using rb_wait_for_single_fd</li>
<li>readline: use rb_wait_for_single_fd() instead of rb_thread_fd_select()</li>
<li>io.c (IO.select): use rb_wait_for_single_fd for single IO case</li>
<li>rb_wait_for_single_fd: use poll() on Linux</li>
</ol>
<p>Also available in my git repo:<br>
git pull git://bogomips.org/ruby rb_wait_for_single_fd</p> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=167512011-05-03T22:43:45Zkosaki (Motohiro KOSAKI)kosaki.motohiro@gmail.com
<ul></ul><p>Please do NOT send untested patch. :-/</p>
<p>% ./ruby-single-wait benchmark/bm_io_select3.rb<br>
max fd: 100000 (results not apparent with <= 1024 max fd)<br>
benchmark/bm_io_select3.rb:15: [BUG] Segmentation fault<br>
ruby 1.9.3dev (2011-05-03 trunk 31412) [x86_64-linux]</p>
<p>-- Control frame information -----------------------------------------------<br>
c:0007 p:---- s:0021 b:0021 l:000020 d:000020 CFUNC :select<br>
c:0006 p:0019 s:0016 b:0016 l:000738 d:000015 BLOCK benchmark/bm_io_select3.rb:15<br>
c:0005 p:---- s:0014 b:0014 l:000013 d:000013 FINISH<br>
c:0004 p:---- s:0012 b:0012 l:000011 d:000011 CFUNC :times<br>
c:0003 p:0094 s:0009 b:0009 l:000738 d:001e00 EVAL benchmark/bm_io_select3.rb:14<br>
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH<br>
c:0001 p:0000 s:0002 b:0002 l:000738 d:000738 TOP</p>
<p>-- Ruby level backtrace information ----------------------------------------<br>
benchmark/bm_io_select3.rb:14:in <code><main>' benchmark/bm_io_select3.rb:14:in </code>times'<br>
benchmark/bm_io_select3.rb:15:in <code>block in <main>' benchmark/bm_io_select3.rb:15:in </code>select'</p>
<p>-- C level backtrace information -------------------------------------------<br>
./ruby-single-wait() [0x528508] vm_dump.c:797<br>
./ruby-single-wait() [0x572226] error.c:249<br>
./ruby-single-wait(rb_bug+0xb1) [0x573631] error.c:266<br>
./ruby-single-wait() [0x4b8420] signal.c:624<br>
/lib64/libpthread.so.0() [0x33bf20eeb0]<br>
/lib64/libc.so.6() [0x33bea884bb]<br>
./ruby-single-wait(rb_thread_fd_select+0x340) [0x5307e0] thread.c:2393<br>
./ruby-single-wait() [0x42e00c] io.c:7298<br>
./ruby-single-wait(rb_ensure+0xab) [0x41758b] eval.c:745<br>
./ruby-single-wait() [0x434d27] io.c:7713<br>
./ruby-single-wait() [0x524a2d] vm_insnhelper.c:403<br>
./ruby-single-wait() [0x519224] insns.def:1012<br>
./ruby-single-wait() [0x51eb8e] vm.c:1163<br>
./ruby-single-wait() [0x51f8e5] vm.c:574<br>
./ruby-single-wait(rb_yield+0x44) [0x525504] vm.c:604<br>
./ruby-single-wait() [0x446861] numeric.c:3225<br>
./ruby-single-wait() [0x524a2d] vm_insnhelper.c:403<br>
./ruby-single-wait() [0x519224] insns.def:1012<br>
./ruby-single-wait() [0x51eb8e] vm.c:1163<br>
./ruby-single-wait(rb_iseq_eval_main+0xbf) [0x525e3f] vm.c:1404<br>
./ruby-single-wait() [0x4147d2] eval.c:215<br>
./ruby-single-wait(ruby_run_node+0x34) [0x416da4] eval.c:262<br>
./ruby-single-wait() [0x414379] main.c:38<br>
/lib64/libc.so.6(__libc_start_main+0xfd) [0x33bea1ee5d]<br>
./ruby-single-wait() [0x414269]</p>
<p>-- Other runtime information -----------------------------------------------</p>
<ul>
<li>
<p>Loaded script: benchmark/bm_io_select3.rb</p>
</li>
<li>
<p>Loaded features:</p>
<p>0 enumerator.so<br>
1 /home/kosaki/ruby/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so<br>
2 /home/kosaki/ruby/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so<br>
3 /home/kosaki/ruby/lib/ruby/1.9.1/rubygems/defaults.rb<br>
4 /home/kosaki/ruby/lib/ruby/1.9.1/tsort.rb<br>
5 /home/kosaki/ruby/lib/ruby/1.9.1/rubygems/dependency_list.rb<br>
6 /home/kosaki/ruby/lib/ruby/1.9.1/x86_64-linux/rbconfig.rb<br>
7 /home/kosaki/ruby/lib/ruby/1.9.1/rubygems/exceptions.rb<br>
8 /home/kosaki/ruby/lib/ruby/1.9.1/rubygems/custom_require.rb<br>
9 /home/kosaki/ruby/lib/ruby/1.9.1/rubygems.rb</p>
</li>
<li>
<p>Process memory map:</p>
</li>
</ul>
<p>00400000-00625000 r-xp 00000000 fd:03 2626950 /home/kosaki/linux/ruby/ruby-single-wait<br>
00824000-00827000 rw-p 00224000 fd:03 2626950 /home/kosaki/linux/ruby/ruby-single-wait<br>
00827000-0083f000 rw-p 00000000 00:00 0<br>
014b6000-032bf000 rw-p 00000000 00:00 0 [heap]<br>
33be200000-33be21f000 r-xp 00000000 fd:00 4980738 /lib64/ld-2.13.so<br>
33be41e000-33be41f000 r--p 0001e000 fd:00 4980738 /lib64/ld-2.13.so<br>
33be41f000-33be420000 rw-p 0001f000 fd:00 4980738 /lib64/ld-2.13.so<br>
33be420000-33be421000 rw-p 00000000 00:00 0<br>
33bea00000-33beb91000 r-xp 00000000 fd:00 4980744 /lib64/libc-2.13.so<br>
33beb91000-33bed91000 ---p 00191000 fd:00 4980744 /lib64/libc-2.13.so<br>
33bed91000-33bed95000 r--p 00191000 fd:00 4980744 /lib64/libc-2.13.so<br>
33bed95000-33bed96000 rw-p 00195000 fd:00 4980744 /lib64/libc-2.13.so<br>
33bed96000-33bed9c000 rw-p 00000000 00:00 0<br>
33bee00000-33bee02000 r-xp 00000000 fd:00 4980748 /lib64/libdl-2.13.so<br>
33bee02000-33bf002000 ---p 00002000 fd:00 4980748 /lib64/libdl-2.13.so<br>
33bf002000-33bf003000 r--p 00002000 fd:00 4980748 /lib64/libdl-2.13.so<br>
33bf003000-33bf004000 rw-p 00003000 fd:00 4980748 /lib64/libdl-2.13.so<br>
33bf200000-33bf217000 r-xp 00000000 fd:00 4980758 /lib64/libpthread-2.13.so<br>
33bf217000-33bf416000 ---p 00017000 fd:00 4980758 /lib64/libpthread-2.13.so<br>
33bf416000-33bf417000 r--p 00016000 fd:00 4980758 /lib64/libpthread-2.13.so<br>
33bf417000-33bf418000 rw-p 00017000 fd:00 4980758 /lib64/libpthread-2.13.so<br>
33bf418000-33bf41c000 rw-p 00000000 00:00 0<br>
33bf600000-33bf684000 r-xp 00000000 fd:00 4980756 /lib64/libm-2.13.so<br>
33bf684000-33bf883000 ---p 00084000 fd:00 4980756 /lib64/libm-2.13.so<br>
33bf883000-33bf884000 r--p 00083000 fd:00 4980756 /lib64/libm-2.13.so<br>
33bf884000-33bf885000 rw-p 00084000 fd:00 4980756 /lib64/libm-2.13.so<br>
33bfa00000-33bfa15000 r-xp 00000000 fd:00 4980798 /lib64/libgcc_s-4.5.1-20100924.so.1<br>
33bfa15000-33bfc14000 ---p 00015000 fd:00 4980798 /lib64/libgcc_s-4.5.1-20100924.so.1<br>
33bfc14000-33bfc15000 rw-p 00014000 fd:00 4980798 /lib64/libgcc_s-4.5.1-20100924.so.1<br>
33c0200000-33c0207000 r-xp 00000000 fd:00 4980764 /lib64/librt-2.13.so<br>
33c0207000-33c0406000 ---p 00007000 fd:00 4980764 /lib64/librt-2.13.so<br>
33c0406000-33c0407000 r--p 00006000 fd:00 4980764 /lib64/librt-2.13.so<br>
33c0407000-33c0408000 rw-p 00007000 fd:00 4980764 /lib64/librt-2.13.so<br>
33caa00000-33caa07000 r-xp 00000000 fd:00 4980814 /lib64/libcrypt-2.13.so<br>
33caa07000-33cac07000 ---p 00007000 fd:00 4980814 /lib64/libcrypt-2.13.so<br>
33cac07000-33cac08000 r--p 00007000 fd:00 4980814 /lib64/libcrypt-2.13.so<br>
33cac08000-33cac09000 rw-p 00008000 fd:00 4980814 /lib64/libcrypt-2.13.so<br>
33cac09000-33cac37000 rw-p 00000000 00:00 0<br>
33cae00000-33cae5d000 r-xp 00000000 fd:00 4980811 /lib64/libfreebl3.so<br>
33cae5d000-33cb05c000 ---p 0005d000 fd:00 4980811 /lib64/libfreebl3.so<br>
33cb05c000-33cb05e000 rw-p 0005c000 fd:00 4980811 /lib64/libfreebl3.so<br>
33cb05e000-33cb062000 rw-p 00000000 00:00 0<br>
7f6892403000-7f68924e3000 rw-p 00000000 00:00 0<br>
7f6892509000-7f689250b000 r-xp 00000000 fd:03 1725292 /home/kosaki/ruby/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so<br>
7f689250b000-7f689270a000 ---p 00002000 fd:03 1725292 /home/kosaki/ruby/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so<br>
7f689270a000-7f689270b000 rw-p 00001000 fd:03 1725292 /home/kosaki/ruby/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so<br>
7f689270b000-7f689270d000 r-xp 00000000 fd:03 1725319 /home/kosaki/ruby/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so<br>
7f689270d000-7f689290c000 ---p 00002000 fd:03 1725319 /home/kosaki/ruby/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so<br>
7f689290c000-7f689290d000 rw-p 00001000 fd:03 1725319 /home/kosaki/ruby/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so<br>
7f689290d000-7f689290e000 ---p 00000000 00:00 0<br>
7f689290e000-7f6892a12000 rw-p 00000000 00:00 0<br>
7f6892a12000-7f68988a2000 r--p 00000000 fd:00 277164 /usr/lib/locale/locale-archive<br>
7f68988a2000-7f68988a7000 rw-p 00000000 00:00 0<br>
7f68988c1000-7f68988c3000 rw-p 00000000 00:00 0<br>
7fffc64c8000-7fffc64e9000 rw-p 00000000 00:00 0 [stack]<br>
7fffc652e000-7fffc652f000 r-xp 00000000 00:00 0 [vdso]<br>
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]</p>
<p>[NOTE]<br>
You may have encountered a bug in the Ruby interpreter or extension libraries.<br>
Bug reports are welcome.<br>
For details: <a href="http://www.ruby-lang.org/bugreport.html" class="external">http://www.ruby-lang.org/bugreport.html</a></p>
<p>zsh: abort (core dumped) ./ruby-single-wait benchmark/bm_io_select3.rb</p> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=167522011-05-04T00:23:13Znormalperson (Eric Wong)normalperson@yhbt.net
<ul></ul><p>Motohiro KOSAKI <a href="mailto:kosaki.motohiro@gmail.com" class="email">kosaki.motohiro@gmail.com</a> wrote:</p>
<blockquote>
<p>Issue <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: [PATCH 0/7] use poll() instead of select() in certain cases (Closed)" href="https://redmine.ruby-lang.org/issues/4531">#4531</a> has been updated by Motohiro KOSAKI.</p>
<p>Please do NOT send untested patch. :-/</p>
<p>% ./ruby-single-wait benchmark/bm_io_select3.rb<br>
max fd: 100000 (results not apparent with <= 1024 max fd)<br>
benchmark/bm_io_select3.rb:15: [BUG] Segmentation fault<br>
ruby 1.9.3dev (2011-05-03 trunk 31412) [x86_64-linux]</p>
</blockquote>
<p>I can't reproduce on my end, same architecture and base revision, too...<br>
I just rebased cleanly off r31415 and still can't reproduce.</p>
<blockquote>
<p>-- C level backtrace information -------------------------------------------<br>
./ruby-single-wait() [0x528508] vm_dump.c:797<br>
./ruby-single-wait() [0x572226] error.c:249<br>
./ruby-single-wait(rb_bug+0xb1) [0x573631] error.c:266<br>
./ruby-single-wait() [0x4b8420] signal.c:624<br>
/lib64/libpthread.so.0() [0x33bf20eeb0]<br>
/lib64/libc.so.6() [0x33bea884bb]<br>
./ruby-single-wait(rb_thread_fd_select+0x340) [0x5307e0] thread.c:2393</p>
</blockquote>
<p>My patches don't touch the rb_thread_fd_select() code. thread.c:2393<br>
is in rb_fd_copy(), not rb_thread_fd_select(), and is the following:</p>
<pre><code>memcpy(dst->fdset, src, size);
</code></pre>
<p>Shouldn't that be:</p>
<pre><code>memcpy(dst->fdset, src->fdset, size);
</code></pre>
<p>since r31395?</p> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=167532011-05-04T08:23:11Zkosaki (Motohiro KOSAKI)kosaki.motohiro@gmail.com
<ul></ul><blockquote>
<p>My patches don't touch the rb_thread_fd_select() code. Â thread.c:2393<br>
is in rb_fd_copy(), not rb_thread_fd_select(), and is the following:</p>
<p>Â memcpy(dst->fdset, src, size);</p>
<p>Shouldn't that be:</p>
<p>Â memcpy(dst->fdset, src->fdset, size);</p>
<p>since r31395?</p>
</blockquote>
<p>Right. Thanks for good catching.<br>
I'll test your patch again.</p> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=167542011-05-04T08:30:51Zkosaki (Motohiro KOSAKI)kosaki.motohiro@gmail.com
<ul></ul><p>Your patch improve single fd case. but slightly decrease multiple fd case.<br>
The most important usecase of IO.select is web server application (ie multiple fd case).<br>
It's no good trade-off.</p>
<p>name before ruby 1.9.3dev (2011-05-03 trunk 31415) [x86_64-linux]<br>
io_select 2.282 1.596<br>
io_select2 56.223 3.097<br>
io_select3 13.470 13.628</p> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=167552011-05-04T09:29:25Zkosaki (Motohiro KOSAKI)kosaki.motohiro@gmail.com
<ul></ul><hr>
<p>int<br>
rb_wait_for_single_fd(int fd, int events, struct timeval *tv)<br>
{<br>
(snip)<br>
BLOCKING_REGION({<br>
result = poll(&fds, 1, timeout);<br>
if (result < 0) lerrno = errno;<br>
}, ubf_select, GET_THREAD());</p>
<pre><code>if (result > 0) {
/* remain compatible with select(2)-based implementation */
result = (int)(fds.revents & fds.events);
return result == 0 ? events : result;
}
</code></pre>
<hr>
<p>It's really unclear comment. select_internal() doesn't have such quirk.<br>
Can you please clarify this?</p>
<hr>
<p>static VALUE<br>
select_internal(VALUE read, VALUE write, VALUE except, struct timeval *tp, rb_fdset_t <em>fds)<br>
{<br>
(snip)<br>
n = rb_thread_fd_select(max, rp, wp, ep, tp);<br>
if (n < 0) {<br>
rb_sys_fail(0);<br>
}<br>
if (!pending && n == 0) return Qnil; /</em> returns nil on timeout */</p> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=167562011-05-04T10:16:18Zkosaki (Motohiro KOSAKI)kosaki.motohiro@gmail.com
<ul></ul><p>I've commited following five patches.</p>
<p>0001-rb_wait_for_single_fd-initial-implementation.patch<br>
0002-io-wait-switch-to-rb_wait_for_single_fd.patch<br>
0003-ext-socket-init.c-simplify-wait_connectable-using-rb.patch<br>
0004-readline-use-rb_wait_for_single_fd-instead-of-rb_thr.patch<br>
0006-rb_wait_for_single_fd-use-poll-on-Linux.patch</p>
<p>But I haven't commited below one patch.</p>
<p>0005-io.c-IO.select-use-rb_wait_for_single_fd-for-single-.patch</p>
<p>I'm waiting performance fix or explanation why should we commit it.</p> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=167572011-05-04T10:23:13Zkosaki (Motohiro KOSAKI)kosaki.motohiro@gmail.com
<ul></ul><p>+int<br>
+rb_wait_for_single_fd(int fd, int events, struct timeval *tv)<br>
+{</p>
<ul>
<li>struct pollfd fds;</li>
<li>int result, lerrno;</li>
<li>double start;</li>
<li>int timeout = tv ? tv->tv_sec * 1000 + (tv->tv_usec + 500) / 1000 : -1;</li>
</ul>
<p>no overflow check?</p> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=167582011-05-04T11:23:12Znormalperson (Eric Wong)normalperson@yhbt.net
<ul></ul><p>Motohiro KOSAKI <a href="mailto:kosaki.motohiro@gmail.com" class="email">kosaki.motohiro@gmail.com</a> wrote:</p>
<blockquote>
<p>I've commited following five patches.</p>
<p>0001-rb_wait_for_single_fd-initial-implementation.patch<br>
0002-io-wait-switch-to-rb_wait_for_single_fd.patch<br>
0003-ext-socket-init.c-simplify-wait_connectable-using-rb.patch<br>
0004-readline-use-rb_wait_for_single_fd-instead-of-rb_thr.patch<br>
0006-rb_wait_for_single_fd-use-poll-on-Linux.patch</p>
</blockquote>
<p>Thanks, I'm preparing some comments + tests in response to your<br>
comments on 0006.</p>
<blockquote>
<p>But I haven't commited below one patch.</p>
<p>0005-io.c-IO.select-use-rb_wait_for_single_fd-for-single-.patch</p>
<p>I'm waiting performance fix or explanation why should we commit it.</p>
</blockquote>
<p>I'm OK with rejecting 0005. It's too ugly in retrospect...</p>
<p>Instead the io/wait extension should be expanded to be able to check for<br>
writability, too. Maybe by adding a new method:</p>
<pre><code>IO#wait_writable(timeout = 0)
</code></pre>
<p>--<br>
Eric Wong</p> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=167592011-05-04T11:45:57Znormalperson (Eric Wong)normalperson@yhbt.net
<ul><li><strong>File</strong> <a href="/attachments/1628">rb_wait_for_single_fd-followup.mbox</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/1628/rb_wait_for_single_fd-followup.mbox">rb_wait_for_single_fd-followup.mbox</a> added</li></ul><p>3 more safety patches + tests based on your comments in this thread:</p>
<ol>
<li>rb_wait_for_single_fd: explain return value for poll() users</li>
<li>rb_wait_for_single_fd: have poll()-using impl set EBADF</li>
<li>rb_wait_for_single_fd: check for invalid timeval</li>
</ol>
<p>Also available at:</p>
<p>git pull git://bogomips.org/ruby rb_wait_for_single_fd-followup</p> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=167602011-05-04T13:23:13Zkosaki (Motohiro KOSAKI)kosaki.motohiro@gmail.com
<ul></ul><p>diff --git a/ext/-test-/wait_for_single_fd/wait_for_single_fd.c<br>
b/ext/-test-/wait_for_single_fd/wait_for_single_fd.c<br>
index d406724..6efd1af 100644<br>
--- a/ext/-test-/wait_for_single_fd/wait_for_single_fd.c<br>
+++ b/ext/-test-/wait_for_single_fd/wait_for_single_fd.c<br>
@@ -25,6 +25,7 @@ Init_wait_for_single_fd(void)<br>
rb_define_const(rb_cObject, "RB_WAITFD_IN", INT2NUM(RB_WAITFD_IN));<br>
rb_define_const(rb_cObject, "RB_WAITFD_OUT", INT2NUM(RB_WAITFD_OUT));<br>
rb_define_const(rb_cObject, "RB_WAITFD_PRI", INT2NUM(RB_WAITFD_PRI));</p>
<ul>
<li>rb_define_const(rb_cObject, "INT_MAX", INT2NUM(INT_MAX));<br>
rb_define_singleton_method(rb_cIO, "wait_for_single_fd",<br>
wait_for_single_fd, 3);</li>
</ul>
<p>Strongly disagree. Any language change should be passed matz review.</p>
<p>@@ -2723,7 +2736,14 @@ rb_wait_for_single_fd(int fd, int events,<br>
struct timeval *tv)<br>
struct pollfd fds;<br>
int result, lerrno;<br>
double start;</p>
<ul>
<li>int timeout = tv ? tv->tv_sec * 1000 + (tv->tv_usec + 500) / 1000 : -1;</li>
</ul>
<ul>
<li>int timeout = -1;</li>
<li>
<li>if (tv) {</li>
<li>
<pre><code> timeout = timeval2msec(tv);
</code></pre>
</li>
<li>
<pre><code> if (timeout == -1) {
</code></pre>
</li>
<li>
<pre><code> return -1;
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>}</li>
</ul>
<p>No good solusion. backend change should be transparent from caller.<br>
I recommend following two way.</p>
<ol>
<li>
<p>use ppoll(2) if available. and use INT_MAX if unavailable. or</p>
</li>
<li>
<p>fallback select(2)</p>
</li>
<li>
<p>is safe because linux has ppol(2).</p>
<p>if (result > 0) {</p>
</li>
</ol>
<ul>
<li>
<pre><code> /* remain compatible with select(2)-based implementation */
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> /*
</code></pre>
</li>
<li>
<pre><code> * Remain compatible with the select(2)-based implementation:
</code></pre>
</li>
<li>
<pre><code> * 1) mask out poll()-only revents such as POLLHUP/POLLERR
</code></pre>
</li>
<li>
<pre><code> * 2) In case revents only consists of masked-out events, return all
</code></pre>
</li>
<li>
<pre><code> * requested events in the result and force the caller to make an
</code></pre>
</li>
<li>
<pre><code> * extra syscall (e.g. read/write/send/recv) to get the error.
</code></pre>
</li>
<li>
<pre><code> */
result = (int)(fds.revents & fds.events);
return result == 0 ? events : result;
</code></pre>
}</li>
</ul>
<p>I don't understand this. Why does this behavior help to compatible?<br>
When do we use it?</p>
<ol start="2">
<li>rb_wait_for_single_fd: have poll()-using impl set EBADF<br>
is good fix. but a testcase of it introduce ruby level new method.<br>
It's unacceptable. I'll commit only code fix.</li>
</ol> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=167612011-05-04T14:23:13Znormalperson (Eric Wong)normalperson@yhbt.net
<ul></ul><p>KOSAKI Motohiro <a href="mailto:kosaki.motohiro@gmail.com" class="email">kosaki.motohiro@gmail.com</a> wrote:</p>
<blockquote>
<p>diff --git a/ext/-test-/wait_for_single_fd/wait_for_single_fd.c<br>
b/ext/-test-/wait_for_single_fd/wait_for_single_fd.c<br>
index d406724..6efd1af 100644<br>
--- a/ext/-test-/wait_for_single_fd/wait_for_single_fd.c<br>
+++ b/ext/-test-/wait_for_single_fd/wait_for_single_fd.c<br>
@@ -25,6 +25,7 @@ Init_wait_for_single_fd(void)<br>
rb_define_const(rb_cObject, "RB_WAITFD_IN", INT2NUM(RB_WAITFD_IN));<br>
rb_define_const(rb_cObject, "RB_WAITFD_OUT", INT2NUM(RB_WAITFD_OUT));<br>
rb_define_const(rb_cObject, "RB_WAITFD_PRI", INT2NUM(RB_WAITFD_PRI));</p>
<ul>
<li>rb_define_const(rb_cObject, "INT_MAX", INT2NUM(INT_MAX));<br>
rb_define_singleton_method(rb_cIO, "wait_for_single_fd",<br>
wait_for_single_fd, 3);</li>
</ul>
<p>Strongly disagree. Any language change should be passed matz review.</p>
</blockquote>
<p>Huh? ext/-test-/* is only loaded during tests and never installed.<br>
No users see anything in ext/-test-/*</p>
<blockquote>
<ol>
<li>
<p>use ppoll(2) if available. and use INT_MAX if unavailable. or</p>
</li>
<li>
<p>fallback select(2)</p>
</li>
<li>
<p>is safe because linux has ppol(2).</p>
</li>
</ol>
</blockquote>
<p>OK, good point about ppoll(), I forgot that exists. I'll work on that<br>
later or tomorrow.</p>
<blockquote>
<pre><code> if (result > 0) {
</code></pre>
<ul>
<li>
<pre><code> /* remain compatible with select(2)-based implementation */
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> /*
</code></pre>
</li>
<li>
<pre><code> * Remain compatible with the select(2)-based implementation:
</code></pre>
</li>
<li>
<pre><code> * 1) mask out poll()-only revents such as POLLHUP/POLLERR
</code></pre>
</li>
<li>
<pre><code> * 2) In case revents only consists of masked-out events, return all
</code></pre>
</li>
<li>
<pre><code> * requested events in the result and force the caller to make an
</code></pre>
</li>
<li>
<pre><code> * extra syscall (e.g. read/write/send/recv) to get the error.
</code></pre>
</li>
<li>
<pre><code> */
result = (int)(fds.revents & fds.events);
return result == 0 ? events : result;
</code></pre>
}</li>
</ul>
<p>I don't understand this. Why does this behavior help to compatible?<br>
When do we use it?</p>
</blockquote>
<p>We need to ensure rb_wait_for_single_fd(fd, events, timeval) returns<br>
only a subset of its +events+ argument because that's all select() is<br>
capable of.</p>
<p>If poll() returns POLLHUP/POLLERR, we should not expose those flags to<br>
callers of rb_wait_for_single_fd() since it would then behave<br>
differently if poll() or select() were used.</p>
<pre><code> int events = RB_WAITFD_IN | RB_WAITFD_OUT;
int revents = rb_wait_for_single_fd(fd, events, NULL);
/* poll() itself may return POLLERR, but we prevent it from being in
* revents since select() can't return that */
if (revents & RB_WAITFD_IN) {
/* since we don't know POLLERR, we fall back to fail here */
if (read(fd, ...) < 0)
rb_sys_fail(0);
}
if (revents & RB_WAITFD_OUT) {
/* since we don't know POLLERR, we fall back to fail here */
if (write(fd, ...) < 0)
rb_sys_fail(0);
}
/* user code shouldn't care about anything else since it only
* requested RB_WAITFD_IN|RB_WAITFD_OUT */
</code></pre>
<p>--<br>
Eric Wong</p> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=167642011-05-04T17:23:14Zkosaki (Motohiro KOSAKI)kosaki.motohiro@gmail.com
<ul></ul><p>Hi</p>
<p>2011/5/4 Eric Wong <a href="mailto:normalperson@yhbt.net" class="email">normalperson@yhbt.net</a>:</p>
<blockquote>
<p>KOSAKI Motohiro <a href="mailto:kosaki.motohiro@gmail.com" class="email">kosaki.motohiro@gmail.com</a> wrote:</p>
<blockquote>
<p>diff --git a/ext/-test-/wait_for_single_fd/wait_for_single_fd.c<br>
b/ext/-test-/wait_for_single_fd/wait_for_single_fd.c<br>
index d406724..6efd1af 100644<br>
--- a/ext/-test-/wait_for_single_fd/wait_for_single_fd.c<br>
+++ b/ext/-test-/wait_for_single_fd/wait_for_single_fd.c<br>
@@ -25,6 +25,7 @@ Init_wait_for_single_fd(void)<br>
   rb_define_const(rb_cObject, "RB_WAITFD_IN", INT2NUM(RB_WAITFD_IN));<br>
   rb_define_const(rb_cObject, "RB_WAITFD_OUT", INT2NUM(RB_WAITFD_OUT));<br>
   rb_define_const(rb_cObject, "RB_WAITFD_PRI", INT2NUM(RB_WAITFD_PRI));</p>
<ul>
<li>Â Â rb_define_const(rb_cObject, "INT_MAX", INT2NUM(INT_MAX));<br>
   rb_define_singleton_method(rb_cIO, "wait_for_single_fd",<br>
                wait_for_single_fd, 3);</li>
</ul>
<p>Strongly disagree. Any language change should be passed matz review.</p>
</blockquote>
<p>Huh? Â ext/-test-/* is only loaded during tests and never installed.<br>
No users see anything in ext/-test-/*</p>
</blockquote>
<p>Oops, my bad. I misunderstood your diff. ok, I'll commit it.</p>
<blockquote>
<blockquote>
<ol>
<li>
<p>use ppoll(2) if available. and use INT_MAX if unavailable. or</p>
</li>
<li>
<p>fallback select(2)</p>
</li>
<li>
<p>is safe because linux has ppol(2).</p>
</li>
</ol>
</blockquote>
<p>OK, good point about ppoll(), I forgot that exists. Â I'll work on that<br>
later or tomorrow.</p>
</blockquote>
<p>ok.</p>
<blockquote>
<blockquote>
<p>Â Â Â if (result > 0) {</p>
<ul>
<li>Â Â Â /* remain compatible with select(2)-based implementation */</li>
</ul>
<ul>
<li>Â Â Â /*</li>
<li>Â Â Â Â * Remain compatible with the select(2)-based implementation:</li>
<li>Â Â Â Â * 1) mask out poll()-only revents such as POLLHUP/POLLERR</li>
<li>Â Â Â Â * 2) In case revents only consists of masked-out events, return all</li>
<li>Â Â Â Â * Â Â requested events in the result and force the caller to make an</li>
<li>Â Â Â Â * Â Â extra syscall (e.g. read/write/send/recv) to get the error.</li>
<li>Â Â Â Â */<br>
    result</li>
</ul>
</blockquote>
</blockquote> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=167682011-05-05T06:36:01Znormalperson (Eric Wong)normalperson@yhbt.net
<ul><li><strong>File</strong> <a href="/attachments/1630">0001-rb_wait_for_single_fd-use-ppoll-instead-of-poll.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/1630/0001-rb_wait_for_single_fd-use-ppoll-instead-of-poll.patch">0001-rb_wait_for_single_fd-use-ppoll-instead-of-poll.patch</a> added</li></ul><p>I've uploaded a new patch to use ppoll() instead of poll()</p>
<p>Also pullable from git://bogomips.org/ruby rb_wait_for_single_fd-ppoll</p> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=167692011-05-05T06:53:07Znormalperson (Eric Wong)normalperson@yhbt.net
<ul><li><strong>File</strong> <a href="/attachments/1631">0001-add-io-wait-benchmarks.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/1631/0001-add-io-wait-benchmarks.patch">0001-add-io-wait-benchmarks.patch</a> added</li></ul><p>also adding benchmarks for IO#wait since those are improved by poll/ppoll</p> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=167702011-05-05T07:30:12Znormalperson (Eric Wong)normalperson@yhbt.net
<ul></ul><p>Eric Wong <a href="mailto:normalperson@yhbt.net" class="email">normalperson@yhbt.net</a> wrote:</p>
<blockquote>
<p>Instead the io/wait extension should be expanded to be able to check for<br>
writability, too. Maybe by adding a new method:</p>
<p>IO#wait_writable(timeout = 0)</p>
</blockquote>
<p>Should've been:</p>
<pre><code>IO#wait_writable(timeout = nil)
</code></pre>
<p>actually. I created a separate issue/patch for it:</p>
<p><a href="http://redmine.ruby-lang.org/issues/4647" class="external">http://redmine.ruby-lang.org/issues/4647</a></p>
<p>--<br>
Eric Wong</p> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=167942011-05-07T00:02:27Zkosaki (Motohiro KOSAKI)kosaki.motohiro@gmail.com
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=167952011-05-07T00:24:20Zkosaki (Motohiro KOSAKI)kosaki.motohiro@gmail.com
<ul></ul><blockquote>
<p>Eric Wong <a href="mailto:normalperson@yhbt.net" class="email">normalperson@yhbt.net</a> wrote:</p>
<blockquote>
<p>Instead the io/wait extension should be expanded to be able to check for<br>
writability, too. Â Maybe by adding a new method:</p>
<p>Â Â Â IO#wait_writable(timeout</p>
</blockquote>
</blockquote> Ruby master - Feature #4531: [PATCH 0/7] use poll() instead of select() in certain caseshttps://redmine.ruby-lang.org/issues/4531?journal_id=167962011-05-07T00:24:21Zkosaki (Motohiro KOSAKI)kosaki.motohiro@gmail.com
<ul></ul><blockquote>
<p>Issue <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: [PATCH 0/7] use poll() instead of select() in certain cases (Closed)" href="https://redmine.ruby-lang.org/issues/4531">#4531</a> has been updated by Eric Wong.</p>
<p>File 0001-rb_wait_for_single_fd-use-ppoll-instead-of-poll.patch added</p>
<p>I've uploaded a new patch to use ppoll() instead of poll()</p>
<p>Also pullable from git://bogomips.org/ruby rb_wait_for_single_fd-ppoll</p>
</blockquote>
<p>I've commited modified patch based on it at r31450.</p>