Review: Use reader/writer spin locks for ustring table. - #126
Merged
Conversation
Contributor
There was a problem hiding this comment.
Is the compiler guaranteed to leave this alone ?
Collaborator
Author
There was a problem hiding this comment.
atomic int has the actual bits underneath "volatile"
Contributor
There was a problem hiding this comment.
Should be ok I guess, since m_readers is atomic and inspecting its value expands to either a function call, an intrinsic or some inline assembler depending on the compilation environment. Any code using atomics is already subtly outside the C++98 standard memory model AFAIK, so guaranteeing behaviour becomes a bit difficult. I'm pretty confident the above would be ok in the C++11 standard though...
Contributor
|
LGTM |
1 similar comment
Contributor
|
LGTM |
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.
I wrote a reader/writer spin lock, used it for the ustring table, and it produces another significant improvement when there's heavy contention in ustring creation. In particular, with this patch the ustring performance continues to improve all the way up to the number of threads greater than the number of cores, whereas previously it "leveled off" earlier, with at some point additional HT cores not providing any additional benefit. Now, more cores always benefit. (For just a few cores, performance is the same as before.)
Now that this class is written, we could possibly improve performance by finding other places where a good spin rw lock is appropriate that's currently a purely exclusive lock.