grpc-java icon indicating copy to clipboard operation
grpc-java copied to clipboard

Create an API to set Cronet read buffer size

Open aymanm-google opened this issue 5 months ago • 1 comments

Is your feature request related to a problem?

When Cronet is used as the underlying transport engine for GRPC. The default read buffer size created is quite small (4KB). This small buffer can lead to overhead especially when reading a significant amount of data (~10s MB) as each read call will incur JNI calls to fetch data from Cronet's networking thread. I believe that the default should be bumped up to 64KB. However, it'd be nice to start with adding an API that allows user to set their own read buffer size per Channel.

Describe the solution you'd like

Add a new API CronetChannelBuilder.setReadBufferSize(...) to allow changing the default buffer size for read operations.

Describe alternatives you've considered

Bump the default to a higher number (64KB)

Additional context

We're doing some experiments regarding moving folks from Cronet to HttpEngine (Cronet in the platform). And we've noticed some latency regressions only on long-running requests which led to this investigation that GRPC-Cronet is using excessively small buffers.

aymanm-google avatar Jul 02 '25 16:07 aymanm-google

Being discussed in https://github.com/grpc/grpc-java/issues/12198

AgraVator avatar Sep 29 '25 05:09 AgraVator