Skip to content

Commit

Permalink
Keep the pipeline handler queue small initially
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jasontedor committed Feb 23, 2017
1 parent afea592 commit 30cdefc
Showing 1 changed file with 3 additions and 5 deletions.
Expand Up @@ -33,7 +33,8 @@
*/
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;

Expand All @@ -45,9 +46,6 @@ public class HttpPipeliningHandler extends ChannelDuplexHandler {
private int readSequence;
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.
*
Expand All @@ -56,7 +54,7 @@ public class HttpPipeliningHandler extends ChannelDuplexHandler {
*/
public HttpPipeliningHandler(final int maxEventsHeld) {
this.maxEventsHeld = maxEventsHeld;
this.holdingQueue = new PriorityQueue<>(INITIAL_EVENTS_HELD);
this.holdingQueue = new PriorityQueue<>(1);
}

@Override
Expand Down

0 comments on commit 30cdefc

Please sign in to comment.