On Fri, 3 Sep 2021 22:29:19 GMT, Brian Burkhalter <b...@openjdk.org> wrote:
> This request proposes to modify `java.io.FilterInputStream` to override > `readAllBytes()`, `readNBytes(int)`, `skipNBytes(long)`, and > `transferTo(OutputStream)` in order to leverage any performance advantage > that the wrapped stream might have over the `java.io.InputStream` > implementations of these methods. A quick and dirty benchmark of `readAllBytes()` and `readNBytes(int)` revealed throughput thrice that of the version without these overrides. The benchmark consisted of calling these methods on a `BufferedInputStream` with a buffer size of 1 MB wrapping a `FileInputStream` opened on a file of size 1 MB. **Before:** Benchmark Mode Cnt Score Error Units ReadNBytes.readAllBytes thrpt 5 2735.935 ± 26.461 ops/s ReadNBytes.readNBytes thrpt 5 2735.949 ± 16.348 ops/s **After:** Benchmark Mode Cnt Score Error Units ReadNBytes.readAllBytes thrpt 5 8245.034 ± 135.084 ops/s ReadNBytes.readNBytes thrpt 5 8320.554 ± 104.707 ops/s ------------- PR: https://git.openjdk.java.net/jdk/pull/5367