jean.boussier / gmail.com wrote:
> In this case, how would you feel about another patch to add
> `splice` support to `IO.copy_file`?

Sure!

> My use case is that I need to efficiently write from a socket
> to a pipe, and sometimes the machine is CPU limited, so the
> performance tank when using `write(read())`.

> Since IIRC you are the author of io_splice, you might have
> insights as of why `IO.copy_stream` doesn't try to use it?

Laziness and caution:

In the past (Linux 2.6.1x and maybe 2.6.2x), splice could hang,
leak memory or corrupt data.  This was definitely a problem on
CentOS 5.x around 2007/2008 and I had to reboot machines after
trying it :x

And I hit problems with it even in 3.7.3:
  https://lore.kernel.org/r/20130119044957.GA25395 / dcvr.yhbt.net

Nowadays, it's probably OK :)

CentOS 5.x is no longer supported and I'm not sure if anybody
still uses Linux 2.6.1x/2.6.2x.  I guess 2.6.32+ is a safe
target (CentOS 6.x+), but I haven't followed CentOS in a while,
now; and I don't think any LTS 3.x+ kernels have unfixed problems.

Fwiw, I usually use non-blocking I/O with pipes, and
IO.copy_stream isn't useful for non-blocking I/O.  However,
[Feature #13618] (auto-fiber) could make IO.copy_stream for
non-blocking pipes more compelling.

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>