From f85a7aed37ff8354d7fbe6ef25c648bf9ce1602e Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Thu, 23 Feb 2017 14:17:46 -0500 Subject: [PATCH] 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 --- .../http/netty4/pipelining/HttpPipeliningHandler.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/pipelining/HttpPipeliningHandler.java b/modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/pipelining/HttpPipeliningHandler.java index 89ad2c70d6d2e..54cdbd3ba9d47 100644 --- a/modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/pipelining/HttpPipeliningHandler.java +++ b/modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/pipelining/HttpPipeliningHandler.java @@ -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 holdingQueue; private final int maxEventsHeld; @@ -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 holdingQueue; - /** * 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) { this.maxEventsHeld = maxEventsHeld; - this.holdingQueue = new PriorityQueue<>(INITIAL_EVENTS_HELD); + this.holdingQueue = new PriorityQueue<>(1); } @Override