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

Use Relaxed ordering mode #210

Merged
merged 1 commit into from
Jun 20, 2024
Merged

Use Relaxed ordering mode #210

merged 1 commit into from
Jun 20, 2024

Conversation

pfreixes
Copy link
Contributor

The Relaxed ordering mode is much more efficient than SeqCst and its good enough for the use case of either loading statistics or updating the current statistic with a delta.

I had a wrong understanding of the ordering mode and I apologize for the confusion. I have updated the code to use Relaxed ordering mode instead of SeqCst. This will make the code more efficient and will be good enough for the use case of either loading statistics or updating the current statistic with a delta.

As an example here for example what ordering mode is used by tokio for incrementing the number of threads created.

There is a good explanation about the semantics of the ordering parameter in this book, specifically this section, which explains that the memory ordering is about the ordering of the atomic instructions rather than the synchronization of the threads for a specific memory address

The Relaxed ordering mode is much more efficient than SeqCst and its
good enough for the use case of either loading statistics or updating
the current statistic with a delta.
@djc djc merged commit 89e9e11 into djc:main Jun 20, 2024
7 of 8 checks passed
@djc
Copy link
Owner

djc commented Jun 20, 2024

Makes sense, thanks!

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