RFR: 8316156: (ch) Channels.newOutputStream(ch).write(bigByteArray) allocates a lot of direct memory [v3]

Brian Burkhalter bpb at openjdk.org
Thu Sep 14 19:35:41 UTC 2023


On Thu, 14 Sep 2023 15:51:53 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> src/java.base/share/classes/sun/nio/ch/ChannelInputStream.java line 49:
>> 
>>> 47:  */
>>> 48: class ChannelInputStream extends InputStream {
>>> 49:     static final int DEFAULT_BUFFER_SIZE = 8192;
>> 
>> Since this buffer size is now being used in more places, is it worth testing with 16KiB to match `InputStream` from https://github.com/openjdk/jdk/pull/11783?
>> 
>> Suggestion:
>> 
>>     static final int DEFAULT_BUFFER_SIZE = 16384;
>> 
>> 
>> 
>> https://github.com/openjdk/jdk/blob/11d431b2c436d6b2a0aa7a00d676a93c1b87da0e/src/java.base/share/classes/java/io/InputStream.java#L56
>
> I can look into running a benchmark on this.

A quick measurement suggests that doubling the buffer size to 16384 would increase `read` throughput by more than 15%, and `write` throughput by more than 40%.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15733#discussion_r1326429932


More information about the nio-dev mailing list