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

Paul Sandoz paul.sandoz at oracle.com
Thu Dec 21 18:28:31 UTC 2017


Hi,

This looks ok, i think it’s definitely reached it’s complexity budget, and arguably over spent.

—

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.

Paul.


> On 21 Dec 2017, at 08:32, Brian Burkhalter <brian.burkhalter at oracle.com> wrote:
> 
> On Dec 21, 2017, at 3:05 AM, Alan Bateman <Alan.Bateman at oracle.com> wrote:
> 
>> On 20/12/2017 22:30, Brian Burkhalter wrote:
>>> :
>>> http://cr.openjdk.java.net/~bpb/8193832/webrev.03/
>>> 
>>> The patch is updated to:
>>> 
>>> * use Peter’s approach to avoid allocating an ArrayList when length <= DEFAULT_BUFFER_SIZE;
>>> * use the default ArrayList constructor instead of that with a specific initial capacity;
>>> * update the test to ensure that lengths which require three buffers are covered.
>>> 
>> This version looks okay although fragile to maintain due to the code paths.
>> 
>> Have you checked that the updated test covers all cases?
> 
> I think it covers all of them except the OOME. I’ll review it again.
> 
> Brian



More information about the core-libs-dev mailing list