Skip to content

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