RFR: 8304745: Lazily initialize byte[] in java.io.BufferedInputStream [v8]

Alan Bateman alanb at openjdk.org
Sat Mar 25 09:07:33 UTC 2023


On Sat, 25 Mar 2023 05:55:46 GMT, Eirik Bjorsnos <duke at openjdk.org> wrote:

> I think the benchmark would benefit with a few words explaining why you focused on those methods/calling patterns. For someone walking past this benchmark, this is not obvious why you picked those.

I think the interesting case is where a BIS is created and either not used, or isn't used for a long time. We have this with System.in where it has 8k byte[] that isn't used until something reads from System.in.

The other case is is a read of 8k or more (or rather than BIS's internal buffer size) and no previous reads/buffered bytes. The subtle thing in the benchmark is that readAllBytes attempts to read 16k so it will bypass the internal buffer before it gets created. I agree that should be documented in the comments or the benchmark changed to read 16k or something large so it's more obvious what it does.

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

PR Comment: https://git.openjdk.org/jdk/pull/13150#issuecomment-1483770874


More information about the core-libs-dev mailing list