Skip to content
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

fix: Revert "fix:replace mutex with atomic value in pika_conf" #2636

Merged
merged 1 commit into from
May 7, 2024

Conversation

cheniujh
Copy link
Collaborator

@cheniujh cheniujh commented May 7, 2024

Reverts #2622
Due to the significant droping of QPS and the increasing of latency

@github-actions github-actions bot added Invalid PR Title ☢️ Bug Something isn't working labels May 7, 2024
@cheniujh cheniujh removed the ☢️ Bug Something isn't working label May 7, 2024
@cheniujh cheniujh changed the title Revert "fix:replace mutex with atomic value in pika_conf" Revert: "fix:replace mutex with atomic value in pika_conf" May 7, 2024
@cheniujh cheniujh changed the title Revert: "fix:replace mutex with atomic value in pika_conf" fix: Revert "fix:replace mutex with atomic value in pika_conf" May 7, 2024
@AlexStocks AlexStocks merged commit b15bdcf into unstable May 7, 2024
12 of 16 checks passed
cheniujh added a commit to cheniujh/pika that referenced this pull request May 7, 2024
@AlexStocks
Copy link
Collaborator

“一些开发者在即使不必要时也尤其喜欢使用 std::atomic 的 load 和 store 函数,因为这在代码中显式表明了这个变量不 “正常”。强调这一事实并非没有道理。因为访问 std::atomic 确实会比 non-std::atomic 更慢一些,我们也看到了 std::atomic 会阻止编译器对代码执行一些特定的,本应被允许的顺序重排。调用 load 和 store 可以帮助识别潜在的可扩展性瓶颈。从正确性的角度来看,没有看到在一个变量上调用 store 来与其他线程进行通信(比如用个 flag 表示数据的可用性)可能意味着该变量在声明时本应使用而没有使用 std::atomic。”

atomic 会阻止编译器对 C++ 代码打乱排序重新优化

from https://cntransgroup.github.io/EffectiveModernCppChinese/7.TheConcurrencyAPI/item40.html

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


"Some developers prefer to use std::atomic's load and store functions even when they are not necessary, because this explicitly indicates in the code that the variable is not "normal". It is not unreasonable to emphasize this fact. Because accessing std ::atomic is indeed slower than non-std::atomic, and we have also seen that std::atomic prevents the compiler from performing certain reordering of the code that should be allowed. Calling load and store can help. Identify potential scalability bottlenecks. From a correctness perspective, not seeing a store call on a variable to communicate with other threads (such as using a flag to indicate the availability of data) may mean that the variable was not declared when it was declared. std::atomic should be used instead."

atomic will prevent the compiler from re-optimizing C++ code out of order

from https://cntransgroup.github.io/EffectiveModernCppChinese/7.TheConcurrencyAPI/item40.html

chenbt-hz pushed a commit to chenbt-hz/pika that referenced this pull request Jun 3, 2024
bigdaronlee163 pushed a commit to bigdaronlee163/pika that referenced this pull request Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants