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

Fix improper activeThreads increments (issue 1842) #1845

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ydidukh
Copy link

@ydidukh ydidukh commented Sep 6, 2024

Purpose

Resolves issue 1842 - Improper threads synchronization in the ThreadBarrier leading to snapshot failures.

Goals

Fix the logic of the ThreadBarrier class to not increment activeThreads counter when threadBarrier.enter() is called in the same thread for which the counter has already been incremented. Used ThreadLocal to maintain counter of enter method invocations within the current thread. Used custom wrapper class MutualInteger for it as it's 5-6x faster than use of threadLocal's get() and set():

ThreadLocalBenchmark.testAtomicInteger 838.083 us/op
ThreadLocalBenchmark.testGetAndSet 3431.792 us/op
ThreadLocalBenchmark.testMutableInteger 558.584 us/op

Security checks

@CLAassistant
Copy link

CLAassistant commented Sep 6, 2024

CLA assistant check
All committers have signed the CLA.

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

Successfully merging this pull request may close these issues.

2 participants