Skip to content
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

https://github.com/LinShunKang/MyPerf4J,4c0a98d8f0f93733b0fddbb2b4b3dd4edd32470d,MyPerf4J-Base,cn.myperf4j.base.util.concurrent.AtomicIntHashCounterTest.testMultiThread4HighRace/testMultiThread4LowRace #936

Open
CaseyPan opened this issue Nov 9, 2023 · 0 comments

Comments

@CaseyPan
Copy link
Contributor

CaseyPan commented Nov 9, 2023

The test is addressed in this issue and has inspired a developer fix at this commit.

  1. Test Overview:
    Location: Myperf4j-Base/util/concurrent/AtomicIntHashCounterTest.java
    Test : testMultiThread4HighRace and testMultiThread4LowRace

    The 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.

  2. 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 message IllegalArgumentException if nThreads <= 0.
    The author initially set the threadCnt to availableProcessors() - 2 to maybe avoid occupying too many computing resources. However, when the machine we use has less than 2 processors, an error will arise.

  3. Changes:

    • Use 1 as thread count when when the machine we use has less than 2 processors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant