-
Notifications
You must be signed in to change notification settings - Fork 2k
More scalable QTP prototype #13505
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
base: jetty-12.1.x
Are you sure you want to change the base?
More scalable QTP prototype #13505
Conversation
@ManagedObject("A striped thread pool") | ||
public class StripedQueuedThreadPool extends ContainerLifeCycle implements ThreadFactory, SizedThreadPool, Dumpable, TryExecutor, VirtualThreads.Configurable | ||
{ | ||
private static final int STRIPES = 16; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be configurable, perhaps default to the number of cores.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also need to reduce striping for small pools. If max threads is 100, then slicing 16 ways is too much.
} | ||
|
||
@Override | ||
public void setMaxThreads(int threads) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a check that threads
should be an exact multiple of STRIPES?
} | ||
|
||
@Override | ||
public void setMinThreads(int threads) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a check that threads
should be an exact multiple of STRIPES?
Also, threads
should be divided by STRIPES.
@Override | ||
public int getMinThreads() | ||
{ | ||
return queuedThreadPools[0].getMinThreads(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stripe this.
throw new IllegalArgumentException("max threads (" + maxThreads + ") less than min threads (" + minThreads + ")"); | ||
for (int i = 0; i < queuedThreadPools.length; i++) | ||
{ | ||
queuedThreadPools[i] = new QueuedThreadPool(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be added as beans.
@Override | ||
protected void doStart() throws Exception | ||
{ | ||
super.doStart(); | ||
for (QueuedThreadPool queuedThreadPool : queuedThreadPools) | ||
{ | ||
queuedThreadPool.start(); | ||
} | ||
} | ||
|
||
@Override | ||
protected void doStop() throws Exception | ||
{ | ||
super.doStop(); | ||
for (QueuedThreadPool queuedThreadPool : queuedThreadPools) | ||
{ | ||
queuedThreadPool.stop(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this if the striped QTP are added as beans, which is also better for dump purposes.
setIdleTimeout(60000); | ||
setStopTimeout(5000); | ||
setReservedThreads(-1); | ||
// setThreadPoolBudget(new ThreadPoolBudget(this)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole ThreadPoolBudget
implementation needs to be reworked, we should first confirm we want to go with this solution.
8a5ccb6
to
4d517ca
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need to stripe the whole QTP? Can't we just stripe the queue itself (and make it not maintain a strict ordering). AI thinks it can be done and has written a version... but I'm also thinking that a ConcurrentPool might be usable?
@ManagedObject("A striped thread pool") | ||
public class StripedQueuedThreadPool extends ContainerLifeCycle implements ThreadFactory, SizedThreadPool, Dumpable, TryExecutor, VirtualThreads.Configurable | ||
{ | ||
private static final int STRIPES = 16; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also need to reduce striping for small pools. If max threads is 100, then slicing 16 ways is too much.
Striping the queue would have my preference, and the fact that we don't need a queue that strictly enforces FIFO (despite the fact that it would break the Maybe we could give the conversant disruptor or the JCTools MPMC |
Despite the shortcomings, a striped QTP is still our best option IMHO. |
Signed-off-by: Ludovic Orban <[email protected]>
4d517ca
to
6800c1a
Compare
…dPool Signed-off-by: Ludovic Orban <[email protected]>
6800c1a
to
10cfdcd
Compare
I tried several variations of the jctools queue in the QTP JMH benchmark and all were slower (30k - 100k ops/s) than BAQ (300k ops/s). |
Signed-off-by: Ludovic Orban <[email protected]>
ea58469
to
e3c7b04
Compare
Prototype
QueuedThreadPool
alternative that stripes execution requests.