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.

Relates elastic#23335
  • Loading branch information
jasontedor authored Feb 23, 2017
1 parent 09b3c7f commit f85a7ae
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
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 f85a7ae

Please sign in to comment.