On Fri, 2 Jul 2021 06:20:29 GMT, Markus KARG 
<github.com+1701815+mk...@openjdk.org> wrote:

>> This PR-*draft* is **work in progress** and an invitation to discuss a 
>> possible solution for issue 
>> [JDK-8265891](https://bugs.openjdk.java.net/browse/JDK-8265891). It is *not 
>> yet* intended for a final review.
>> 
>> As proposed in JDK-8265891, this PR provides an implementation for 
>> `Channels.newInputStream().transferTo()` which provide superior performance 
>> compared to the current implementation. The changes are:
>> * 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 more JRE heap in the fallback case when no NIO is possible (still 
>> only KiBs, hence mostl ynegligible even on SBCs) to better perform on modern 
>> hardware / fast I/O devides.
>> 
>> 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. So this PoC proofs that 
>> it makes sense to finalize this work and turn it into an actual OpenJDK 
>> contribution. 
>> 
>> I encourage everybody to discuss this draft:
>> * Are there valid arguments for *not* doing this change?
>> * Is there a *better* way to improve performance of 
>> `Channels.newInputStream().transferTo()`?
>> * How to go on from here: What is missing to get this ready for an actual 
>> review?
>
> Markus KARG has refreshed the contents of this pull request, and previous 
> commits have been removed. The incremental views will show differences 
> compared to the previous content of the PR.

I cloned the `InputStream/TransferTo` test in a way which uses providers, but 
when started to implement the providers I noticed that a huge amount of *empty* 
source code is needed just to make the compiler happy: `FileChannel` already 
has dozens of abstract methods I have to override but they never will be used 
by any of the tests... Having that said, it would be good if I would be allowed 
to spare us thousands of useless codelines:
* May I just implement the `content()` test or do you insist on me really 
implementing *all* the tests found in `InputStream/TransferTo` for *each* of 
the overloaded `transferTo` implementations?
* May I use a mocking framework to actually just provide *partial* 
implementations of the channels, or do you insist on me actually overloading 
*all* methods of *all* channels in actual Java source code just for the sake of 
making the compiler happy?

While I understand the necessity of tests, and while I am convinced that the 
performance benefit outweighs the weeks of work this would imply just for 
adding all those test code, I actually like to propose that I only cover the 
`content()` tests plus using Mockito, so we would have 80% of the benefit for 
20% of the coding costs.

WDYT?

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

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

Reply via email to