RFR: 8265175: (fs) Files.copy(Path, Path, CopyOption...) should use sendfile on Linux [v3]
Brian Burkhalter
bpb at openjdk.java.net
Thu Apr 15 18:39:04 UTC 2021
On Thu, 15 Apr 2021 11:10:00 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> Brian Burkhalter has updated the pull request incrementally with three additional commits since the last revision:
>>
>> - Merge
>> - 8265175: Delete fstat() calls, read to EOF, change sendfile() to sendfile64(), handle EINTR case
>> - 8265175: (fs) Files.copy(Path,Path,CopyOption...) should use sendfile on Linux
>
> src/java.base/unix/native/libnio/fs/UnixCopyFile.c line 79:
>
>> 77: return;
>> 78: }
>> 79: #endif
>
> This version looks much better but it missing the error checking. If bytes_sent is -1 then we should throw UnixException with the errno like the existing code.
>
> What would you think about setting count to 1MB or 4MB so that there is at least some chance for cancellation when the file is huge.
>
> Given that the new implementation will call sendfile64 until EOF then there is no reason to fall through to the old implementation, the old implementation goes into the #else ...
Changing `count` to 1MB and 4MB instead of 2147479552 bytes somewhat surprisingly did not have a huge effect on the throughput for the two largest transfer sizes tested.
-------------
PR: https://git.openjdk.java.net/jdk/pull/3476
More information about the nio-dev
mailing list