On Thu, 12 Aug 2021 01:16:04 GMT, Brian Burkhalter <b...@openjdk.org> wrote:

> Please consider this request to add an override 
> `java.io.FileInputStream.transferTo(OutputStream)` with improved performance 
> if the parameter is a `FileOutputStream`.

Invoking `transferTo()` on a `FileInputStream` will use the superclass method 
which copies using looping over buffers of a fixed size. If the parameter is a 
`FileOutputStream`, the copy is greatly accelerated by using the 
`java.nio.channels.FileChannel.transferTo()` method with the `FileChannel`s of 
the source and destination streams. Performance measurements were made for 
streams of length 100000, 1000000, 100000000, and 1000000000 bytes. Throughput 
improvement was observed for all cases on the three usual platforms, with the 
largest of nearly  5X being seen on Linux because in this case the sendfile() 
system call is used underneath. In no case did throughput decrease.

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

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

Reply via email to