minor improvements#328
Merged
Merged
Conversation
When an enqueue fails due to racing with a dequeue, it needs to undo the insertion of a state into the upcoming queue tail. This CAS is guaranteed to succeed. So there is no need to take the overhead of a `CMPXCHG` in this path. We can instead rephrase this code to preserve the assertion but weaken the operations involved into non-atomic `MOV`s. Profiling with some medium sized models indicates this has no significant effect on performance. But it may help models that have a different pattern where threads often contend on the same queue.
The style this code is written in is intended to prioritise:
1. White space independence (e.g. no // comments). This code is
currently copied as-is into the output but in future we might do
some sort of white space coalescing.
2. Density/readability. Hence why this change removes bracing on
single-line ifs, gaining back a line of display.
I think eventually I will probably decide this does not matter and accept all clang-format suggestions. But I am still in some phase of cope.
On x86-64, users should be compiling with `-mcx16`. But if they do not, double-word CAS is implemented by a libatomic call. In this case it is unsafe to use AVX stores/loads for double-word write/read (respectively) because, although they are atomic, they do not synchronise with the (possibly lock acquiring) double-word CAS.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.