RFR: 8276779: (ch) InputStream returned by Channels.newInputStream should have fast path for SelectableChannels [v12]

Alan Bateman alanb at openjdk.java.net
Wed Nov 10 08:38:46 UTC 2021


On Wed, 10 Nov 2021 07:21:14 GMT, Markus KARG <duke at openjdk.java.net> wrote:

>> 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 deliberately concentrates **only** on `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).
>> 
>> **Update:** This sub-issue *only* defines the work to be done to implement JDK-8265891 *solely* for the particular case of FileChannel.transferTo(WriteableByteChannel), including special treatment of SelectableByteChannel, as the `master` branch already contains code to handle the specific case of FileChannel.transferTo(FileChannel).
>
> Markus KARG has updated the pull request incrementally with one additional commit since the last revision:
> 
>   JavaDoc proposal by Alan Bateman

> > If you update if the PR with the javadoc changes then we can agree them here before you create the CSR.
> 
> Please find and discuss the CSR Javadoc proposal by @AlanBateman in [fcf616e](https://github.com/openjdk/jdk/commit/fcf616e2b86f92ad20425e018c42be2fe4cef0df). Thanks.

Thanks, I'm happy with this. As I suggested this wording then it would be good if @bplb also reviews the CSR.

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

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


More information about the nio-dev mailing list