From: normalperson@... Date: 2015-07-20T20:22:04+00:00 Subject: [ruby-core:70051] [Ruby trunk - Feature #11377] [Open] [PATCH] IO.copy_stream uses poll on Linux Issue #11377 has been reported by Eric Wong. ---------------------------------------- Feature #11377: [PATCH] IO.copy_stream uses poll on Linux https://bugs.ruby-lang.org/issues/11377 * Author: Eric Wong * Status: Open * Priority: Normal * Assignee: Eric Wong ---------------------------------------- poll and ppoll have a superior API which doesn't require the kernel to scan a potentially large bitmap to find a high-numbered FD [ruby-core:35572]. So favor using poll in case IO.copy_stream encounters a non-blocking FD. We cannot reliably use poll on most OSes, because file types (e.g. FIFOs) which work with select may not work with poll. Fortunately, Linux uses a common notification mechanism between all select/poll/epoll variants, so all file types are equally supported between the notification mechanisms. Verified by watching strace on the following scripts: *** maygvl_copy_stream_wait_read *** require 'io/nonblock' r, w = IO.pipe r.nonblock = true IO.copy_stream(r, "/dev/null") *** nogvl_copy_stream_wait_write *** require 'io/nonblock' r, w = IO.pipe w.nonblock = true IO.copy_stream("/dev/zero", w) * io.c (nogvl_wait_for_single_fd): new function for Linux (maygvl_copy_stream_wait_read): Linux-specific version (nogvl_copy_stream_wait_write): use nogvl_wait_for_single_fd ---Files-------------------------------- 0001-io.c-IO.copy_stream-uses-poll-on-Linux.patch (3.75 KB) -- https://bugs.ruby-lang.org/