RFR: JDK-8273038: ChannelInputStream.transferTo() uses FileChannel.transferTo(FileChannel) [v5]

Markus KARG github.com+1701815+mkarg at openjdk.java.net
Sun Aug 29 08:25:38 UTC 2021


> As proposed in JDK-8265891, this PR provides an implementation for `Channels.newInputStream().transferTo()` which provide superior performance compared to the current implementation. This PR is a spin-off from https://github.com/openjdk/jdk/pull/4263 and https://github.com/openjdk/jdk/pull/5179 and deliberately concentrates **only** on the case where both, source **and** target, are actually `FileChannel`s. Other types of channels will be discussed in future PRs.
> 
> * Prevents transfers through the JVM heap as much as possibly by offloading to deeper levels via NIO, hence allowing the operating system to optimize the transfer.
> 
> Using JMH I have benchmarked both, the original implementation and this implementation, and (depending on the used hardware and use case) performance change was approx. doubled performance. A rather similar approach in different use casse was recently implemented by https://github.com/openjdk/jdk/pull/5097 which was reported by even provide 5x performance (https://github.com/openjdk/jdk/pull/5097#issuecomment-897271997).

Markus KARG has updated the pull request incrementally with one additional commit since the last revision:

  Testing random starting point within source
  
  Signed-off-by: Markus Karg <markus at headcrashing.eu>

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

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/5209/files
  - new: https://git.openjdk.java.net/jdk/pull/5209/files/205b9b21..e9163bf4

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=5209&range=04
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=5209&range=03-04

  Stats: 36 lines in 1 file changed: 30 ins; 1 del; 5 mod
  Patch: https://git.openjdk.java.net/jdk/pull/5209.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/5209/head:pull/5209

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


More information about the nio-dev mailing list