Conversation
|
Thanks for adding the thorough PR description (Explains the changes really well!) |
yashdeep97
reviewed
Oct 13, 2023
| if (availableThreads <= 1) { | ||
| throw new RuntimeException("Multithreading is not supported on this system with " + | ||
| availableThreads + " available processors."); | ||
| } else if (availableThreads >= 2 && availableThreads <= 3) { |
There was a problem hiding this comment.
Could you please elaborate on why you chose to assign threadCnt = 2 when there are 2 or 3 available processors?
I think the authors might have an issue if both processors get used since their primary motive was to keep 2 processors available for other computing tasks.
In case of 3 available threads, maybe we can assign just one thread since that is what the authors initially intended? (However, I'm not 100% sure if this is the best approach)
|
Could you please update the PR by addressing the above comments? |
This file contains hidden or 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
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.
What is the purpose of the change
Fix #101
Brief ChangeLog
Test Overview:
Location:
Myperf4j-Base/util/concurrent/AtomicIntHashCounterTest.javaTest :
testMultiThread4HighRaceandtestMultiThread4LowRaceThe two test are designed to assess the behavior of a multi-threaded scenario with varying levels of contention, and they use random parameters to perform a large number of iterations to test the stability and correctness of the tested code.
Reason of flakiness:
ExecutorService newFixedThreadPool(int nThreads)method creates a thread pool that reuses a fixed number of threads operating off a shared unbounded queue. And it will throw error messageIllegalArgumentExceptionifnThreads <= 0.The author initially set the
threadCnttoavailableProcessors() - 2to maybe avoid occupying too many computing resources. However, when the machine we use has less than 2 processors, an error will arise.Changes:
availableThreadsto store the number of available processors.threadCntto handle cases with different number of available processors.availableThreads - 2threads, which is consistent with the original code.Verifying this change
Follow this checklist to help us incorporate your contribution quickly and easily:
[MyPerf4J-XXX] Fix NullPointerException when host is null #XXX. Each commit in the pull request should have a meaningful subject line and body.mvn clean package -Dmaven.test.skip=falseto make sure unit-test pass.