Skip to content

Commit

Permalink
Grow request queue instead of pre-allocating it
Browse files Browse the repository at this point in the history
To avoid excess allocation, in particular for higher values of
`MaxRequestsQueuedPerDestination`, the per-destination request queue is
now initialized with a capacity of 32 entries and configured to grow 32
entries at a time until the maximum is reached.

Resolves #8319.
  • Loading branch information
marcphilipp authored and sbordet committed Jul 28, 2022
1 parent eb6ff57 commit 4a6c274
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ protected ConnectionPool newConnectionPool(HttpClient client)

protected Queue<HttpExchange> newExchangeQueue(HttpClient client)
{
return new BlockingArrayQueue<>(client.getMaxRequestsQueuedPerDestination());
int maxCapacity = client.getMaxRequestsQueuedPerDestination();
if (maxCapacity > 32)
return new BlockingArrayQueue<>(32, 32, maxCapacity);
return new BlockingArrayQueue<>(maxCapacity);
}

protected ClientConnectionFactory newSslClientConnectionFactory(SslContextFactory.Client sslContextFactory, ClientConnectionFactory connectionFactory)
Expand Down

0 comments on commit 4a6c274

Please sign in to comment.