Skip to content

Use Relaxed ordering mode#210

Merged
djc merged 1 commit into
djc:mainfrom
pfreixes:use_relaxed_mode
Jun 20, 2024
Merged

Use Relaxed ordering mode#210
djc merged 1 commit into
djc:mainfrom
pfreixes:use_relaxed_mode

Conversation

@pfreixes

Copy link
Copy Markdown

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
@djc

djc commented Jun 20, 2024

Copy link
Copy Markdown
Owner

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