RFR: 8274112: (fc) Tune FileChannel.transferTo() [v5]
Brian Burkhalter
bpb at openjdk.java.net
Tue Apr 12 23:57:41 UTC 2022
On Tue, 12 Apr 2022 23:50:33 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>> Please consider this patch which would improve the performance of
>> `FileChannel.transferTo()` on macOS and Windows.
>
> Brian Burkhalter has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains six additional commits since the last revision:
>
> - 8274112: Remove native read-write copy; add threshold for mapped copy; use Linux copy_file_range() for direct copy if available
> - Merge
> - 8274112: Make transferTo0() static; remove check for null FileDescriptor
> - 8274112: Modify transfer_read_write() not to throw if read or write fails
> - 8274112: Refactor to use transferToFileChannel()
> - 8274112: (fc) Tune FileChannel.transferTo()
Commit 65e3adcaf5ec2a4635a1962c2bf70a5ca802c121 makes the following changes:
1. removes `transferToFileChannel()` and its associated logic and read-write native code;
2. adds a transfer size threshold below which trusted transfer will fall back to arbitrary transfer;
3. uses `copy_file_range(2)` instead of `sendfile(2)` for direct transfer on Linux when possible.
The effects of these changes are:
- the logic is simplified and the amount of native code changed is greatly reduced;
- non-direct transfers below the trusted transfer size threshold are faster (verified on Linux, macOS, and Windows);
- direct transfers larger than 0x7ffff000 (2,147,479,552) bytes to a file channel may be made on Linux if `copy_file_range()` is available (verified on Linux).
-------------
PR: https://git.openjdk.java.net/jdk/pull/5623
More information about the nio-dev
mailing list