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
Limit the number of Scheduler#disposeGracefully threads #3259
Conversation
This change modifies the `DisposeAwaiter` interface in order to be able to poll for graceful shutdown termination status rather than await/block for it. It introduces a DisposeAwaiterRunnable with a small pool of threads dedicated to polling the termination status after a graceful Scheduler shutdown. Previously, one Thread would be created for each Scheduler that is disposed gracefully. While we don't expect this to be an issue in most production applications, this can lead to hitting native thread limits faster. Notably, stress tests around graceful disposal create a lot of schedulers for that purpose.
currently seeing another type of OOM issue:
|
we couldn't get to the bottom of the OOMs on M1 machines, but it seems to still significantly improve the situation, and most notably on CI. the last commit removes stress tests for |
reactor-core/src/jcstress/java/reactor/core/scheduler/BasicSchedulersStressTest.java
Outdated
Show resolved
Hide resolved
@@ -174,6 +144,11 @@ public void arbiter(IIZ_Result r) { | |||
// by r.r1 and r.r2, which should be equal. | |||
boolean consistentState = r.r1 == r.r2; | |||
r.r3 = consistentState && scheduler.isDisposed(); | |||
if (consistentState) { |
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.
👍
reactor-core/src/main/java/reactor/core/scheduler/BoundedElasticScheduler.java
Outdated
Show resolved
Hide resolved
@simonbasle this PR seems to have been merged on a maintenance branch, please ensure the change is merge-forwarded to intermediate maintenance branches and up to |
merged into |
This change introduces a `DisposeAwaiterRunnable` with a small pool of threads dedicated to polling the termination status after a graceful Scheduler shutdown. Previously, one Thread would be created for each Scheduler that is disposed gracefully. While we don't expect this to be an issue in most production applications, this can lead to hitting native thread limits faster. Notably, stress tests around graceful disposal create a lot of schedulers for that purpose. This change also ensures that the evictor executorServices of both the BoundedElasticScheduler and ElasticScheduler are limited to at most 1 thread. Finally, it attempts to improve the SchedulersStressTest to avoid the OOMs as much as possible: block on disposeGracefully() calls, increase the heap of forked JVMs for jcstress, and ultimately stop covering the BoundedElasticScheduler in the stress test. Fixes #3258.
This change introduces a
DisposeAwaiterRunnable
with a small pool ofthreads dedicated to polling the termination status after a graceful
Scheduler shutdown.
Previously, one Thread would be created for each Scheduler that is
disposed gracefully. While we don't expect this to be an issue in most
production applications, this can lead to hitting native thread limits
faster. Notably, stress tests around graceful disposal create a lot of
schedulers for that purpose.
This change also ensures that the evictor executorServices of both the
BoundedElasticScheduler and ElasticScheduler are limited to at most 1
thread.
Finally, it attempts to improve the SchedulersStressTest to avoid the
OOMs as much as possible: block on disposeGracefully() calls, increase
the heap of forked JVMs for jcstress, and ultimately stop covering the
BoundedElasticScheduler in the stress test.
Fixes #3258.