-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specialize std::io::copy for files, sockets, or pipes on Linux #74426
Comments
The Linux GNU coreutils also tries to use |
My understanding is that
|
Thanks, I didn't realize it did that! |
Oops, I didn't realize that either. The
Then, if you think there is nothing to do, feel free to close this issue. |
Specializing io::copy may still be useful for generic code operating on |
Tagging T-libs, as it seems like a libs team question whether it would be valid to change the underlying semantics of these copy operations. It sounds like |
Specializing |
Since this would require specializing on the input and output type the naive approach would lead to quadratic blowup of types. So it's probably better to have an internal highly parameterized copy helper and two separate sets of specializations that each prepare one half of the parameter set. |
Currently
std::fs::copy
isusing(edit: it triesstd::io::copy
to copy files - it reads the file content into the memory, and then write it to the output file.std::fs::copy
orcopy_file_range(2)
first and has already benefited from the file cloning feature)std::io::copy
can benefit from the file cloning feature in Btrfs and XFS by usingFICLONE
(and fallbacking to read-write loop if the filesystem does not support it).I think is easy to use
FICLONE
instd::fs::copy
, but it's less general (it requires file paths).std::io::copy
is more general, but some additional methods may be needed to be added tostd::io::Read
andstd::io::Write
in order to useFICLONE
.libuv's support for
FICLONE
: libuv/libuv#1491The
ioctl_ficlonerange(2)
man page: https://www.man7.org/linux/man-pages/man2/ioctl_ficlonerange.2.htmlThe text was updated successfully, but these errors were encountered: