Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions netty/src/main/java/io/grpc/netty/NettyClientHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ static NettyClientHandler newHandler(

Http2Settings settings = new Http2Settings();
settings.pushEnabled(false);
// Netty default, gRPC default: 0x4000 = 16,384 B = 16 KiB
// GRPC_CLIENT_MAX_FRAME_SIZE override default: 64 KiB
// Absolute maximum (inclusive): 0xFFFFFF = 16,777,215 B = (16 MiB - 1 B)
// (defined in https://www.rfc-editor.org/rfc/rfc9113.html#SETTINGS_MAX_FRAME_SIZE)
settings.maxFrameSize(
Integer.parseInt(System.getenv().getOrDefault("GRPC_CLIENT_MAX_FRAME_SIZE", "64")) * 1024);
settings.initialWindowSize(flowControlWindow);
settings.maxConcurrentStreams(0);
settings.maxHeaderListSize(maxHeaderListSize);
Expand Down
13 changes: 12 additions & 1 deletion netty/src/main/java/io/grpc/netty/NettyServerHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,18 @@ static NettyServerHandler newHandler(

final Http2Connection connection = new DefaultHttp2Connection(true);
WeightedFairQueueByteDistributor dist = new WeightedFairQueueByteDistributor(connection);
dist.allocationQuantum(16 * 1024); // Make benchmarks fast again.
// Amount of bytes that will be allocated to each stream.
// Netty default: 1 KiB
// gRPC default: 16 KiB
// gRPC default override: 64 KiB
// Env var default: GRPC_CLIENT_MAX_FRAME_SIZE or 64 KiB
int aq = 64;
if (System.getenv("GRPC_SERVER_STREAM_ALLOCATION_QUANTUM") != null) {
aq = Integer.parseInt(System.getenv("GRPC_SERVER_STREAM_ALLOCATION_QUANTUM"));
} else if (System.getenv("GRPC_CLIENT_MAX_FRAME_SIZE") != null) {
aq = Integer.parseInt(System.getenv("GRPC_CLIENT_MAX_FRAME_SIZE"));
}
dist.allocationQuantum(aq * 1024); // Make benchmarks fast again.
DefaultHttp2RemoteFlowController controller =
new DefaultHttp2RemoteFlowController(connection, dist);
connection.remote().flowController(controller);
Expand Down