Skip to content

Conversation

@blonded04
Copy link

Refactor compiler/threading:

  • Switch to std::atomic instead of volatile
  • Use alignas to cache-align shared structs
  • Use proper memory orderings instead of default seq_cst

blonded04 added 3 commits May 22, 2024 00:00
Signed-off-by: Valery Matskevich <[email protected]>
Signed-off-by: Valery Matskevich <[email protected]>
Copy link
Contributor

@mkornaukhov mkornaukhov left a 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

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) {
Copy link
Contributor

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?

Copy link
Author

@blonded04 blonded04 May 25, 2024

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

blonded04 added 2 commits May 25, 2024 14:39
Signed-off-by: Valery Matskevich <[email protected]>
Signed-off-by: Valery Matskevich <[email protected]>
@blonded04 blonded04 requested a review from mkornaukhov May 25, 2024 11:51
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