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

Uses Acquire/Release semantics for test_accounts_locks_multithreaded() #4225

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

Conversation

brooksprumo
Copy link

@brooksprumo brooksprumo commented Dec 30, 2024

Problem

Similar to #4222, but for a test.

test_accounts_locks_multithreaded() uses Sequential Consistency semantics even though the counter atomic never interacts with another atomic. Thus, sequential consistency is not required for correctness. Additionally, I argue that using sequential consistency when not required is a bug, as it implies a relationship that is otherwise not explicit. Since there is no relationship with another atomic, the code is both (1) less performant, and (2) communicates wrong information to the reader.

Here's the PR where the test was added: solana-labs#4691. I wanted to see if the test originally had another atomic variable, which may've necessitated sequential consistency. Looks like "no".

Summary of Changes

Switch ordering to use Acquire-Release semantics.

I ran this test in a loop on my macbook for 6 hours without any failures as well.

@brooksprumo brooksprumo self-assigned this Dec 30, 2024
@brooksprumo brooksprumo marked this pull request as ready for review December 30, 2024 20:11
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