-
Notifications
You must be signed in to change notification settings - Fork 92
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
Add cacheline-alignment to compiler/threading and switch from volatile to std::atomic #1005
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Valery Matskevich <[email protected]>
Signed-off-by: Valery Matskevich <[email protected]>
Signed-off-by: Valery Matskevich <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, do not break blame
|
||
HTNode *at(unsigned long long hash) { | ||
int i = (unsigned)hash % (unsigned)N; | ||
while (true) { | ||
while (nodes[i].hash != 0 && nodes[i].hash != hash) { | ||
while (nodes[i].hash.load(std::memory_order_acquire) != 0 && nodes[i].hash.load(std::memory_order_relaxed) != hash) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why second read is relaxed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because it won't be reordered between nodes[i].hash.load(std::memory_order_acquire)
before and nodes[i].hash.load(std::memory_order_acquire)
after, the only barrier needed here is load-load, which is imposed by reading node hash
Signed-off-by: Valery Matskevich <[email protected]>
Signed-off-by: Valery Matskevich <[email protected]>
Refactor compiler/threading:
std::atomic
instead ofvolatile
alignas
to cache-align shared structs