Integrated: 8266589: (fs) Improve performance of Files.copy() on macOS using copyfile(3)

Brian Burkhalter bpb at openjdk.java.net
Fri May 7 15:27:21 UTC 2021


On Wed, 5 May 2021 20:51:59 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`.

This pull request has now been integrated.

Changeset: b5b31197
Author:    Brian Burkhalter <bpb at openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/b5b31197e5ab9fda8b9f09367aba280f865d2320
Stats:     42 lines in 1 file changed: 39 ins; 2 del; 1 mod

8266589: (fs) Improve performance of Files.copy() on macOS using copyfile(3)

Reviewed-by: alanb

-------------

PR: https://git.openjdk.java.net/jdk/pull/3890


More information about the nio-dev mailing list