RFR: 8274112: (fc) Tune FileChannel.transferTo()
Brian Burkhalter
bpb at openjdk.java.net
Wed Sep 22 01:35:09 UTC 2021
On Wed, 22 Sep 2021 01:25:37 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
> Please consider this patch which would improve the performance of
> `FileChannel.transferTo()` on macOS and Windows.
On Linux, `sendfile()` was measured to provide faster transfer than either the
trusted channel (mapped buffer copy) or the arbitrary channel (Java read-write)
paths, and an experimental native read-write path. Therefor on Linux no change is
needed.
On macOS, native read-write was measured to be faster than both the trusted and
arbitrary paths. Benchmark results for various lengths are for the trusted path
Benchmark (length) Mode Cnt Score Error Units
TransferTune.transferToFC 1000 thrpt 10 127670.489 ± 1018.466 ops/s
TransferTune.transferToFC 10000 thrpt 10 103345.306 ± 1049.713 ops/s
TransferTune.transferToFC 100000 thrpt 10 36488.102 ± 242.382 ops/s
TransferTune.transferToFC 500000 thrpt 10 9440.104 ± 56.543 ops/s
TransferTune.transferToFC 1000000 thrpt 10 4813.599 ± 78.812 ops/s
TransferTune.transferToFC 10000000 thrpt 10 184.298 ± 4.617 ops/s
TransferTune.transferToFC 100000000 thrpt 10 23.391 ± 0.183 ops/s
TransferTune.transferToFC 500000000 thrpt 10 4.674 ± 0.028 ops/s
TransferTune.transferToFC 1000000000 thrpt 10 2.349 ± 0.010 ops/s
TransferTune.transferToFC 2000000000 thrpt 10 0.993 ± 0.004 ops/s
TransferTune.transferToFC 4000000000 thrpt 10 0.455 ± 0.002 ops/s
and the proposed native read-write path
Benchmark (length) Mode Cnt Score Error Units
TransferTune.transferToFC 1000 thrpt 10 253841.238 ± 1884.480 ops/s
TransferTune.transferToFC 10000 thrpt 10 215629.254 ± 1987.146 ops/s
TransferTune.transferToFC 100000 thrpt 10 48655.924 ± 1060.983 ops/s
TransferTune.transferToFC 500000 thrpt 10 11596.874 ± 126.086 ops/s
TransferTune.transferToFC 1000000 thrpt 10 5889.314 ± 20.170 ops/s
TransferTune.transferToFC 10000000 thrpt 10 364.018 ± 2.149 ops/s
TransferTune.transferToFC 100000000 thrpt 10 31.956 ± 0.277 ops/s
TransferTune.transferToFC 500000000 thrpt 10 6.282 ± 0.090 ops/s
TransferTune.transferToFC 1000000000 thrpt 10 3.134 ± 0.103 ops/s
TransferTune.transferToFC 2000000000 thrpt 10 1.542 ± 0.080 ops/s
TransferTune.transferToFC 4000000000 thrpt 10 0.750 ± 0.087 ops/s
On Windows the native read-write path was also measured to be faster than the trusted path except that beyond a certain limit the trusted path becomes faster than native read-write. The value of this limit appears to be approximately 2MB but more verification might be needed.
-------------
PR: https://git.openjdk.java.net/jdk/pull/5623
More information about the nio-dev
mailing list