RFR 8193832: Performance of InputStream.readAllBytes() could be improved

Brian Burkhalter brian.burkhalter at oracle.com
Thu Dec 21 20:44:23 UTC 2017


On Dec 21, 2017, at 11:44 AM, Paul Sandoz <paul.sandoz at oracle.com> wrote:

>> I concur that this horse is almost dead from the beatings but since I already hacked up Peter’s suggestion which eliminates intermediate copies I might as well hang it out there (see below).
> 
> That looks ok to me, i think keeping the buf allocation at the top of the loop tends to simplify the reasoning.

Agreed. Here’s the hopefully final version:

http://cr.openjdk.java.net/~bpb/8193832/webrev.04/

I think the test case all the cases, i.e., possible data lengths, aside from the OOME case.

>>> I do have one follow on investigation we discussed off list that is worth measuring. At the end use the Unsafe array allocation with no zeroing, since the resulting array will be fully written into. This might result in an observable improvement.
>> 
>> I’ve not forgotten about that but do not know whether we want to include it as part of this issue or a subsequent one.
>> 
> 
> I suggest a follow on investigation.

I’ll file an issue.

Thanks,

Brian


More information about the core-libs-dev mailing list