-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
This reverts commit 14d2297.
“一些开发者在即使不必要时也尤其喜欢使用 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 |
"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 |
本PR Revert了 #2622
因为该PR合并后QPS大幅下降,且p99高了很多
perf下来发现cpu cache miss翻倍,推测是很多原子量落在了同一个cache line上面