-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 max pool size for dynamic parallel execution #3206
Merged
marcphilipp
merged 8 commits into
junit-team:main
from
mpkorstanje:saturate-via-property-dynamic
Apr 23, 2023
Merged
Limit max pool size for dynamic parallel execution #3206
marcphilipp
merged 8 commits into
junit-team:main
from
mpkorstanje:saturate-via-property-dynamic
Apr 23, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is a followup of junit-team#3044 for the `dynamic` strategy. Fixes: junit-team#3205
mpkorstanje
force-pushed
the
saturate-via-property-dynamic
branch
from
March 24, 2023 14:26
64cd26b
to
de89325
Compare
mpkorstanje
commented
Mar 24, 2023
"Factor '%s' specified via configuration parameter '%s' must be greater than or equal to 1", | ||
factor, CONFIG_DYNAMIC_FACTOR_PROPERTY_NAME)); | ||
return maxPoolSizeFactor.multiply(BigDecimal.valueOf(parallelism)).intValue(); | ||
}).orElseGet(() -> 256 + parallelism); |
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.
There are two ways to calculate the max pool size:
maxPoolSize = dynamic.max-pool-size-factor * dynamic.factor * Runtime.getRuntime().availableProcessors()
maxPoolSize = dynamic.max-pool-size-factor * Runtime.getRuntime().availableProcessors()
And the choice is a bit arbitrary. But I think reasoning in terms of "threads per degree of parallelism" is a bit easier so I prefer the former.
marcphilipp
approved these changes
Apr 22, 2023
marcphilipp
requested changes
Apr 22, 2023
mpkorstanje
force-pushed
the
saturate-via-property-dynamic
branch
from
April 23, 2023 12:40
fca3426
to
6849f00
Compare
marcphilipp
approved these changes
Apr 23, 2023
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This is a followup of #3044 for the
dynamic
strategy.With Java 9+ the
ForkJoinPool
used by JUnit can be configured with a maximum pool size via thejunit.jupiter.execution.parallel.config.dynamic.max-pool-size-factor
property.While the number of concurrently executing tests may exceed the configured parallelism factor when tests become blocked, it will not exceed the maximum pool size factor in these circumstances.
With the following configuration:
This example will report between 2 and 4 tests running concurrently on a system with 12 available cores while only (12 * 0.1667 =) 2 would be expected.
By also configuring the
max-pool-size-factor
we can ensure the concurrently executing test does not exceed the expected 2 .junit.jupiter.execution.parallel.config.dynamic.max-pool-size-factor=1
Additionally, because the
ForkJoinPool
will by default reject tasks that would exceed the maximum pool size thejunit.jupiter.execution.parallel.config.dynamic.saturate
property has been added and will default totrue
. There appears to be no reason to ever set thisfalse
but it is there should someone depend on the old behavior.Fixes: #3205
I hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
@API
annotations