Issue #15006 has been reported by byroot (Jean Boussier).

----------------------------------------
Feature #15006: [PATCH] io.c: use copy_file_range with every types of files 
https://bugs.ruby-lang.org/issues/15006

* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Ref: https://bugs.ruby-lang.org/issues/13867

`IO.copy_stream` only attempt to use `copy_file_range` if the source is a regular file.

However from my understanding, contrary to `sendfile` and `splice`, `copy_file_range` has no file type restriction, it should be able to copy from and to sockets and pipes just fine.

It does have very optimized paths for regular files on specific file systems, but for other `fd` types it will fallback to do the copy using the page cache:

https://lwn.net/Articles/659523/

> If the function is absent or returns failure, the kernel will, if the COPY_FR_COPY flag is set, fall back to copying through the page cache.

So if it's available, it's preferable to `nogvl_copy_stream_read_write`.


GitHub PR: https://github.com/ruby/ruby/pull/1932



---Files--------------------------------
copy-file-range.patch (1.56 KB)


-- 
https://bugs.ruby-lang.org/

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