Keep the pipeline handler queue small initially

This commit sets the intial size of the pipeline handler queue small to
prevent waste if pipelined requests are never sent. Since the queue will
grow quickly if pipeline requests are indeed set, this should not be
problematic.

Relates #23335
This commit is contained in:
Jason Tedor 2017-02-23 14:17:46 -05:00 committed by GitHub
parent 09b3c7f270
commit f85a7aed37
1 changed files with 3 additions and 5 deletions

View File

@ -33,7 +33,8 @@ import java.util.PriorityQueue;
*/ */
public class HttpPipeliningHandler extends ChannelDuplexHandler { public class HttpPipeliningHandler extends ChannelDuplexHandler {
private static final int INITIAL_EVENTS_HELD = 8; // we use a priority queue so that responses are ordered by their sequence number
private final PriorityQueue<HttpPipelinedResponse> holdingQueue;
private final int maxEventsHeld; private final int maxEventsHeld;
@ -45,9 +46,6 @@ public class HttpPipeliningHandler extends ChannelDuplexHandler {
private int readSequence; private int readSequence;
private int writeSequence; private int writeSequence;
// we use a priority queue so that responses are ordered by their sequence number
private final PriorityQueue<HttpPipelinedResponse> holdingQueue;
/** /**
* Construct a new pipelining handler; this handler should be used downstream of HTTP decoding/aggregation. * Construct a new pipelining handler; this handler should be used downstream of HTTP decoding/aggregation.
* *
@ -56,7 +54,7 @@ public class HttpPipeliningHandler extends ChannelDuplexHandler {
*/ */
public HttpPipeliningHandler(final int maxEventsHeld) { public HttpPipeliningHandler(final int maxEventsHeld) {
this.maxEventsHeld = maxEventsHeld; this.maxEventsHeld = maxEventsHeld;
this.holdingQueue = new PriorityQueue<>(INITIAL_EVENTS_HELD); this.holdingQueue = new PriorityQueue<>(1);
} }
@Override @Override