RFR: 8266589: (fs) Improve performance of Files.copy() on macOS using copyfile(3) [v2]
Alan Bateman
alanb at openjdk.java.net
Fri May 7 05:19:05 UTC 2021
On Thu, 6 May 2021 19:50:44 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>> Please consider this request to use `fcopyfile(3)` to copy files via `java.nio.file.Files(Path,Path,CopyOption...)` on macOS. This change would improve the throughput of `Files.copy()` as shown in these results:
>>
>> **Copy via 8192 byte buffers**
>>
>>
>> Benchmark (size) Mode Cnt Score Error Units
>> FilesCopy.copy 10240 thrpt 5 5432.671 ± 137.114 ops/s
>> FilesCopy.copy 51200 thrpt 5 3959.145 ± 157.467 ops/s
>> FilesCopy.copy 102400 thrpt 5 2931.325 ± 109.200 ops/s
>> FilesCopy.copy 512000 thrpt 5 655.550 ± 39.919 ops/s
>> FilesCopy.copy 1048568 thrpt 5 375.127 ± 10.111 ops/s
>> FilesCopy.copy 10485760 thrpt 5 64.048 ± 5.740 ops/s
>> FilesCopy.copy 104857600 thrpt 5 6.893 ± 0.415 ops/s
>> FilesCopy.copy 1073741824 thrpt 5 0.717 ± 0.026 ops/s
>>
>>
>> **Copy via fcopyfile**
>>
>>
>> Benchmark (size) Mode Cnt Score Error Units
>> FilesCopy.copy 10240 thrpt 5 5070.255 ± 817.419 ops/s
>> FilesCopy.copy 51200 thrpt 5 4469.218 ± 65.634 ops/s
>> FilesCopy.copy 102400 thrpt 5 3997.718 ± 301.440 ops/s
>> FilesCopy.copy 512000 thrpt 5 2064.223 ± 68.893 ops/s
>> FilesCopy.copy 1048568 thrpt 5 817.743 ± 83.076 ops/s
>> FilesCopy.copy 10485760 thrpt 5 145.799 ± 3.674 ops/s
>> FilesCopy.copy 104857600 thrpt 5 24.706 ± 14.178 ops/s
>> FilesCopy.copy 1073741824 thrpt 5 1.386 ± 0.073 ops/s
>>
>>
>> The smallest size tested shows a small degradation in throughput, but this could be rectified if desired by adding an empirically determined size threshold under which user-space buffers would be used instead of `fcopyfile()`.
>>
>> A small change is also made to the Linux `sendfile()` portion to use the largest permitted `count` value if the copy is uninterruptible, i.e., `cancel == NULL`.
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>
> 8266589: Handle COPYFILE_ERR stage in fcopyfile_callback()
I see the re-examination of the callback means that COPYFILE_ERR is handled now. Good!
-------------
Marked as reviewed by alanb (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/3890
More information about the nio-dev
mailing list