Skip to content

Commit 2f52a00

Browse files
authored
netty: Swap to UniformStreamByteDistributor (#11954)
1 parent 2191557 commit 2f52a00

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

netty/src/main/java/io/grpc/netty/AbstractNettyHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ abstract class AbstractNettyHandler extends GrpcHttp2ConnectionHandler {
5050
private final Ticker ticker;
5151

5252
private static final long BDP_MEASUREMENT_PING = 1234;
53+
protected static final int MIN_ALLOCATED_CHUNK = 16 * 1024;
5354

5455
AbstractNettyHandler(
5556
ChannelPromise channelUnused,

netty/src/main/java/io/grpc/netty/NettyClientHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
import io.netty.handler.codec.http2.Http2Stream;
7979
import io.netty.handler.codec.http2.Http2StreamVisitor;
8080
import io.netty.handler.codec.http2.StreamBufferingEncoder;
81-
import io.netty.handler.codec.http2.WeightedFairQueueByteDistributor;
81+
import io.netty.handler.codec.http2.UniformStreamByteDistributor;
8282
import io.netty.handler.logging.LogLevel;
8383
import io.perfmark.PerfMark;
8484
import io.perfmark.Tag;
@@ -169,8 +169,8 @@ static NettyClientHandler newHandler(
169169
Http2HeadersEncoder.NEVER_SENSITIVE, false, 16, Integer.MAX_VALUE);
170170
Http2FrameWriter frameWriter = new DefaultHttp2FrameWriter(encoder);
171171
Http2Connection connection = new DefaultHttp2Connection(false);
172-
WeightedFairQueueByteDistributor dist = new WeightedFairQueueByteDistributor(connection);
173-
dist.allocationQuantum(16 * 1024); // Make benchmarks fast again.
172+
UniformStreamByteDistributor dist = new UniformStreamByteDistributor(connection);
173+
dist.minAllocationChunk(MIN_ALLOCATED_CHUNK); // Increased for benchmarks performance.
174174
DefaultHttp2RemoteFlowController controller =
175175
new DefaultHttp2RemoteFlowController(connection, dist);
176176
connection.remote().flowController(controller);

netty/src/main/java/io/grpc/netty/NettyServerHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
import io.netty.handler.codec.http2.Http2Settings;
8888
import io.netty.handler.codec.http2.Http2Stream;
8989
import io.netty.handler.codec.http2.Http2StreamVisitor;
90-
import io.netty.handler.codec.http2.WeightedFairQueueByteDistributor;
90+
import io.netty.handler.codec.http2.UniformStreamByteDistributor;
9191
import io.netty.handler.logging.LogLevel;
9292
import io.netty.util.AsciiString;
9393
import io.netty.util.ReferenceCountUtil;
@@ -243,8 +243,8 @@ static NettyServerHandler newHandler(
243243
maxMessageSize);
244244

245245
final Http2Connection connection = new DefaultHttp2Connection(true);
246-
WeightedFairQueueByteDistributor dist = new WeightedFairQueueByteDistributor(connection);
247-
dist.allocationQuantum(16 * 1024); // Make benchmarks fast again.
246+
UniformStreamByteDistributor dist = new UniformStreamByteDistributor(connection);
247+
dist.minAllocationChunk(MIN_ALLOCATED_CHUNK); // Increased for benchmarks performance.
248248
DefaultHttp2RemoteFlowController controller =
249249
new DefaultHttp2RemoteFlowController(connection, dist);
250250
connection.remote().flowController(controller);

0 commit comments

Comments
 (0)