RFR: 8266589: (fs) Improve performance of Files.copy() on macOS using copyfile(3) [v2]
Brian Burkhalter
bpb at openjdk.java.net
Thu May 6 19:50:44 UTC 2021
> 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()
-------------
Changes:
- all: https://git.openjdk.java.net/jdk/pull/3890/files
- new: https://git.openjdk.java.net/jdk/pull/3890/files/84708f5c..ff2d2f9b
Webrevs:
- full: https://webrevs.openjdk.java.net/?repo=jdk&pr=3890&range=01
- incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=3890&range=00-01
Stats: 8 lines in 1 file changed: 4 ins; 0 del; 4 mod
Patch: https://git.openjdk.java.net/jdk/pull/3890.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/3890/head:pull/3890
PR: https://git.openjdk.java.net/jdk/pull/3890
More information about the nio-dev
mailing list