Grow request queue instead of pre-allocating it

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.
This commit is contained in:
Marc Philipp 2022-07-25 09:17:40 +02:00 committed by Simone Bordet
parent eb6ff577ae
commit 4a6c2744a0
1 changed files with 4 additions and 1 deletions

View File

@ -132,7 +132,10 @@ public abstract class HttpDestination extends ContainerLifeCycle implements Dest
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)