Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weak reference concurrent pool #10787

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
acbca5a
Experiment with a weakly referenced ConcurrentPool
gregw Oct 25, 2023
9eebabb
Experiment with a weakly referenced ConcurrentPool
gregw Oct 25, 2023
4fbcb0a
Experiment with a weakly referenced ConcurrentPool
gregw Oct 25, 2023
86ecaa2
Experiment with a weakly referenced ConcurrentPool
gregw Oct 25, 2023
9e3d183
Experiment with a weakly referenced ConcurrentPool
gregw Oct 25, 2023
9218c7d
Experiment with a weakly referenced ConcurrentPool
gregw Oct 25, 2023
9014d68
Experiment with a weakly referenced ConcurrentPool
gregw Oct 26, 2023
db414fd
Merge remote-tracking branch 'origin/jetty-12.0.x' into experiment/je…
gregw Oct 26, 2023
1f91daf
Experiment with a weakly referenced ConcurrentPool
gregw Oct 26, 2023
ae9b7e8
Modify ArrayByteBufferPool and ConcurrentPool to make weak-referencin…
lorban Oct 26, 2023
c0eaa4a
Experiment with a weakly referenced ConcurrentPool
gregw Oct 26, 2023
8ce0260
Experiment with a weakly referenced ConcurrentPool
gregw Oct 27, 2023
11a3dff
Experiment with a weakly referenced ConcurrentPool
gregw Oct 29, 2023
0d54890
Experiment with a weakly referenced ConcurrentPool
gregw Oct 31, 2023
c58905a
Merge branch 'jetty-12.0.x' into experiment/jetty-12/WeakReference-Co…
gregw Oct 31, 2023
bbcc930
A weakly referenced ConcurrentPool
gregw Oct 31, 2023
2604eb6
Merge branch 'jetty-12.0.x' into experiment/jetty-12/WeakReference-Co…
gregw Nov 1, 2023
c28979f
Merge branch 'jetty-12.0.x' into experiment/jetty-12/WeakReference-Co…
gregw Nov 1, 2023
dd53992
A weakly referenced ConcurrentPool
gregw Nov 1, 2023
8799ea4
* Avoid using deprecated ConcurrentPool constructors.
sbordet Nov 9, 2023
3d0fb16
Merged branch 'jetty-12.0.x' into 'experiment/jetty-12/WeakReference-…
sbordet Nov 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ public class DuplexConnectionPool extends AbstractConnectionPool
{
public DuplexConnectionPool(Destination destination, int maxConnections)
{
super(destination, () -> new ConcurrentPool<>(ConcurrentPool.StrategyType.FIRST, maxConnections, false), 1);
super(destination, () -> new ConcurrentPool<>(ConcurrentPool.StrategyType.FIRST, maxConnections), 1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static ToIntFunction<Connection> newMaxMultiplexer(int defaultMaxMultiple

public MultiplexConnectionPool(Destination destination, int maxConnections, int initialMaxMultiplex)
{
this(destination, () -> new ConcurrentPool<>(ConcurrentPool.StrategyType.FIRST, maxConnections, false, newMaxMultiplexer(initialMaxMultiplex)), initialMaxMultiplex);
this(destination, () -> new ConcurrentPool<>(ConcurrentPool.StrategyType.FIRST, maxConnections, newMaxMultiplexer(initialMaxMultiplex)), initialMaxMultiplex);
}

protected MultiplexConnectionPool(Destination destination, Pool.Factory<Connection> poolFactory, int initialMaxMultiplex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ public class RandomConnectionPool extends MultiplexConnectionPool
{
public RandomConnectionPool(Destination destination, int maxConnections, int initialMaxMultiplex)
{
super(destination, () -> new ConcurrentPool<>(ConcurrentPool.StrategyType.RANDOM, maxConnections, false, MultiplexConnectionPool.newMaxMultiplexer(initialMaxMultiplex)), initialMaxMultiplex);
super(destination, () -> new ConcurrentPool<>(ConcurrentPool.StrategyType.RANDOM, maxConnections, MultiplexConnectionPool.newMaxMultiplexer(initialMaxMultiplex)), initialMaxMultiplex);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public RoundRobinConnectionPool(Destination destination, int maxConnections)

public RoundRobinConnectionPool(Destination destination, int maxConnections, int initialMaxMultiplex)
{
super(destination, () -> new ConcurrentPool<>(ConcurrentPool.StrategyType.ROUND_ROBIN, maxConnections, false, newMaxMultiplexer(initialMaxMultiplex)), initialMaxMultiplex);
super(destination, () -> new ConcurrentPool<>(ConcurrentPool.StrategyType.ROUND_ROBIN, maxConnections, newMaxMultiplexer(initialMaxMultiplex)), initialMaxMultiplex);
// If there are queued requests and connections get
// closed due to idle timeout or overuse, we want to
// aggressively try to open new connections to replace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void testMaxDurationConnectionsWithMultiplexedPoolLifecycle() throws Exce
{
int maxConnections = destination.getHttpClient().getMaxConnectionsPerDestination();
int initialMaxMultiplex = 10;
MultiplexConnectionPool connectionPool = new MultiplexConnectionPool(destination, () -> new ConcurrentPool<>(ConcurrentPool.StrategyType.FIRST, maxConnections, false, MultiplexConnectionPool.newMaxMultiplexer(initialMaxMultiplex)), initialMaxMultiplex)
MultiplexConnectionPool connectionPool = new MultiplexConnectionPool(destination, () -> new ConcurrentPool<>(ConcurrentPool.StrategyType.FIRST, maxConnections, MultiplexConnectionPool.newMaxMultiplexer(initialMaxMultiplex)), initialMaxMultiplex)
{
@Override
protected void onCreated(Connection connection)
Expand Down Expand Up @@ -217,7 +217,7 @@ public void testStreamIdleTimeout() throws Exception
{
int maxConnections = destination.getHttpClient().getMaxConnectionsPerDestination();
int initialMaxMultiplex = 10;
MultiplexConnectionPool connectionPool = new MultiplexConnectionPool(destination, () -> new ConcurrentPool<>(ConcurrentPool.StrategyType.FIRST, maxConnections, false, MultiplexConnectionPool.newMaxMultiplexer(initialMaxMultiplex)), initialMaxMultiplex)
MultiplexConnectionPool connectionPool = new MultiplexConnectionPool(destination, () -> new ConcurrentPool<>(ConcurrentPool.StrategyType.FIRST, maxConnections, MultiplexConnectionPool.newMaxMultiplexer(initialMaxMultiplex)), initialMaxMultiplex)
{
@Override
protected void onCreated(Connection connection)
Expand Down Expand Up @@ -292,7 +292,7 @@ public void testMaxDurationConnectionsWithMultiplexedPool() throws Exception
ConnectionPoolFactory factory = new ConnectionPoolFactory("maxDurationConnectionsWithMultiplexedPool", destination ->
{
int maxConnections = destination.getHttpClient().getMaxConnectionsPerDestination();
MultiplexConnectionPool connectionPool = new MultiplexConnectionPool(destination, () -> new ConcurrentPool<>(ConcurrentPool.StrategyType.FIRST, maxConnections, false, MultiplexConnectionPool.newMaxMultiplexer(MAX_MULTIPLEX)), MAX_MULTIPLEX)
MultiplexConnectionPool connectionPool = new MultiplexConnectionPool(destination, () -> new ConcurrentPool<>(ConcurrentPool.StrategyType.FIRST, maxConnections, MultiplexConnectionPool.newMaxMultiplexer(MAX_MULTIPLEX)), MAX_MULTIPLEX)
{
@Override
protected void onCreated(Connection connection)
Expand Down Expand Up @@ -363,7 +363,7 @@ public void testMaxDurationConnectionsWithMultiplexedPoolClosesExpiredConnection
ConnectionPoolFactory factory = new ConnectionPoolFactory("duplex-maxDuration", destination ->
{
int maxConnections = destination.getHttpClient().getMaxConnectionsPerDestination();
MultiplexConnectionPool connectionPool = new MultiplexConnectionPool(destination, () -> new ConcurrentPool<>(ConcurrentPool.StrategyType.FIRST, maxConnections, false, MultiplexConnectionPool.newMaxMultiplexer(MAX_MULTIPLEX)), MAX_MULTIPLEX)
MultiplexConnectionPool connectionPool = new MultiplexConnectionPool(destination, () -> new ConcurrentPool<>(ConcurrentPool.StrategyType.FIRST, maxConnections, MultiplexConnectionPool.newMaxMultiplexer(MAX_MULTIPLEX)), MAX_MULTIPLEX)
{
@Override
protected void onCreated(Connection connection)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,10 @@ private static class RetainedBucket
private RetainedBucket(int capacity, int poolSize)
{
if (poolSize <= ConcurrentPool.OPTIMAL_MAX_SIZE)
_pool = new ConcurrentPool<>(ConcurrentPool.StrategyType.THREAD_ID, poolSize, false);
_pool = new ConcurrentPool<>(ConcurrentPool.StrategyType.THREAD_ID, poolSize, e -> 1);
else
_pool = new CompoundPool<>(
new ConcurrentPool<>(ConcurrentPool.StrategyType.THREAD_ID, ConcurrentPool.OPTIMAL_MAX_SIZE, false),
new ConcurrentPool<>(ConcurrentPool.StrategyType.THREAD_ID, ConcurrentPool.OPTIMAL_MAX_SIZE, e -> 1),
new QueuedPool<>(poolSize - ConcurrentPool.OPTIMAL_MAX_SIZE)
);
_capacity = capacity;
Expand Down
Loading