3 ms·
What is copy_regular_files? All I found is some Rust code which does not use a single syscall as claimed (it takes file descriptors, so you need to open/close i
by CyberShadow 5y ago
What is copy_regular_files? All I found is some Rust code which does not use a single syscall as claimed (it takes file descriptors, so you need to open/close it anyway).
> uses copy acceleration when the file system supports it
I thought that refers to clone_file_range, but that doesn't seem to be the case. As such, I would recommend looking into that, I believe it's supported on btrfs and XFS currently in Linux.
There is also sendfile, but it's probably the same as copy_file_range.
- nieve 5y agoSame, and in fact the benchmarks linked are all in Rust so I suspect the author really means "Fastest way to copy a file in Rust".
- deleted 5y ago[deleted]
- ziml77 5y agoIf the author is looking at a Rust specific function, then the actual advice should be to use File::copy(). That function forwards to OS specific implementations which use copy_file_range on Linux, fcopyfile on macOS, and CopyFileExW on Windows.
- ReleaseCandidat 5y agoIt uses Linux `copy_file_range`. As I wrote in another post, that syscall had already caused some trouble for Go, they used it with `io.Copy()` You can only copy 'non special' files _in _the_same_filesystem_ (that part is missing in Rust's documentioan) with it. https://stdrs.dev/nightly/x86_64-unknown-linux-gnu/std/sys/unix/kernel_copy/fn.copy_regular_files.html https://stdrs.dev/nightly/x86_64-unknown-linux-gnu/std/sys/u...
- SUPERCILEX 5y agoWhoops, author here. That was a mistake, I meant to say the copy_file_range syscall since that's what Rust uses by default under the hood on Linux (or copyfile on macOS). Updated the article with those corrections.