Limit ReservedThread creation
Jetty version(s) 12.1.x
Description If all the threads of a thread pool are taken, and a new request arrives, the job to handle the request is queued, but also the task for a new ReservedThread.
We should count how many pending ReservedThread we attempted to start, and stop when we reach the capacity, to avoid to continuously queue ReservedThread tasks to the thread pool.
A dump showed ~2700 tasks for ReservedThread, which is obviously much more than the ReservedThreadExecutor capacity.
Hello, Do you need help with this issue? I can support it.
@arsenalzp yes, can you spot the problem? Let's discuss it in this issue.
@arsenalzp yes, can you spot the problem? Let's discuss it in this issue.
Hello, Superficially, I understand the meaning of this issue. It is necessary to deep dive into the code.
Ah! We recently removed the accounting for pending threads as we thought it was unnecessary. Obviously not!
If you look back a few tries you will see what we used to do. Maybe we just restore that, or maybe there is something better we can do?
@gregw this is ReservedThreadExecutor and it still has accounting for pending threads.
However, the default is that we have no limit for maxPending, while I think a better default should the capacity.
Given that maxPending=-1 means "unlimited", we can use 0 (currently an invalid value) to mean "default", and we default at capacity.
Because also capacity can be negative (meaning "heuristic"), we need to re-compute maxPending in the constructor with the effective value of capacity.
@arsenalzp can you implement the above in a PR?
@arsenalzp can you implement the above in a PR?
Hello, Let's try it. What is the ultimate term for this improvement?
@arsenalzp the change should be simple, end of month we have a scheduled release, but this issue is not urgent.