dev@grizzly.java.net

Re: buffersize fields in AbstractStreamReader.java ans AbstractStreamWriter.java

From: Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM>
Date: Thu, 23 Jul 2009 14:29:44 +0200

Hi Min Qin,

>
> In Gizzly 2.0.0-M1, when a TCPNIOTransport is created, default
> read buffer and default write buffer are defined as
> DEFAULT_READ_BUFFER_SIZE= 65536 and DEFAULT_WRITE_BUFFER_SIZE =
> 4096. Those two attributes of TCPNIOTransport dominate buffer sizes
> for read and write operations with socket channels without blocking.
> Based on above observations, it seems bufferSize fields in both
> AbstractStreamReader.java and AbstractStreamWriter,java are
> irrelevant to buffer operations with socket channels.
>
> Can we get ride of buffersize fields in both classes?
IMHO not. Buffers, in general, are used to buffer data for read/write
operations to avoid reading/writing data byte by byte. Probably you
mean AbstractStreamReader/Writer could use bufferSizes of Connection
they belong to? Though not sure it will be fine for all usecases like
SSL Reader/Writer

>
> By the way, Can you elaborate rationales of defining
> DEFAULT_READ_BUFFER_SIZE as 65536 and DEFAULT_WRITE_BUFFER_SIZE as
> 4096?
DEFAULT_READ_BUFFER_SIZE = 64K is just aligned (1/2) with buffer size,
allocated per thread by DefaultMemoryManager. The
DEFAULT_WRITE_BUFFER_SIZE=4K is just taken from Grizzly 1.x.
Both values were not optimized yet, so could be changed in future.

Thanks.

WBR,
Alexey.

>
>
>
> Ming Qin
> Cell Phone 858-353-2839