Comments (8)
具体还有很多影响因素,但目前我认为性能下降的原因最终还是归结到加剧了竞争或者是调用自旋锁时延长了锁的占用时间。只要不触犯这两条,基本上问题就不大。感谢您的认可,向您学习。
from workspace.
已在文档说明
from workspace.
看来从理论和实际上,都能得出结论,这种 batch 替换的方式,比直接写入队列 然后去拿,效果好了不少。
我之前尝试过,依次写入队列,然后获取的时候,修改为 获取多个task 去执行的思路。
尝试下来,在空跑的测试环境中,性能是下降的。
预计是在任务有random耗时的情况下, 性能会略有提升。
但是由于纯调度的性能diff,本来就非常小,在有耗时的task的情况下,会被稀释的很厉害。
测试结果就不是那么准确了。
感谢您的回复,希望可以添加到你的个人微信,以便今后经常咨询和讨论。
我的微信是 ChunelFeng
from workspace.
无锁 性能会比 自旋锁 性能高吗
from workspace.
哦,是我理解错了。 如果测试程序锁竞争导致的cache coherency traffic中比较大,可以试试ttas锁。https://rigtorp.se/spinlock/。 不知道性能提升怎么样了。
from workspace.
我可以试着提个Pr
from workspace.
我试了下 https://probablydance.com/2019/12/30/measuring-mutexes-spinlocks-and-how-bad-the-linux-scheduler-really-is/ 这篇文章提到的改进,没什么效果。
struct spinlock {
void lock() {
for (int spin_count = 0; !try_lock(); ++spin_count) {
if (spin_count < 16)
_mm_pause();
else {
std::this_thread::yield();
spin_count = 0;
}
}
}
bool try_lock() {
return !locked.load(std::memory_order_relaxed) &&
!locked.exchange(true, std::memory_order_acquire);
}
void unlock() { locked.store(false, std::memory_order_release); }
private:
std::atomic_bool locked{false};
};
from workspace.
如果用极少的异步线程,且每次推任务时采用批量提交大量的任务(延长锁的占用时间),那么采用这种自旋锁才有可能能提高整体性能,否则可能会因为多做一些无用的yeild导致线程切换从而降低整体性能。
from workspace.
Related Issues (20)
- 稳定性测试脚本的问题 HOT 1
- ubuntu 20下,起进程,这个进程无法关闭 HOT 1
- 请问线程池可以处理高递归的任务吗 HOT 1
- 关于任务窃取机制的疑问 HOT 3
- 关于submitForReturn函数是否能执行带参数的函数的问题 HOT 3
- 卧槽,名字都改掉了 HOT 1
- 建议启用以下cmake功能 HOT 1
- 在Issues中看到了有对应的b站视频,up主能否挂一下链接 HOT 1
- 请教关于workspace HOT 3
- CMakeLists.txt有点问题 HOT 6
- 知乎上看到说这个库还有对应的解析视频?不知道哪里可以看到? HOT 1
- 重构问题 HOT 2
- workbranch::mission里访问workbranch::decline不用加锁吗? HOT 1
- 请求一些意见
- 线程返回超时问题 HOT 2
- 关于win 中引用当前workspace库 使用c++14报错的问题 HOT 4
- 如何取消指定任务? HOT 1
- 空载时CPU占用巨高 HOT 1
- Futures类成员函数返回临时变量的引用 HOT 1
- 动态线程调整相关 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from workspace.