在做task steal的时候多steal一些task
- Dominant language
- C++
- Stars
- 17.6k
- Forks
- 4.1k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 69
Description
**Is your feature request related to a problem? (你需要的功能是否与某个问题有关?)**
在bthread任务创建非常频繁的情况下提高性能
**Describe the solution you'd like (描述你期望的解决方法)**
当前在做task steal的时候,每次只会拿一个任务。在任务创建非常频繁的时候,task steal的原子操作也会成为瓶颈,可以通过一次多拿一些任务来降低这部分的竞争
**Describe alternatives you've considered (描述你想到的折衷方案)**
修改`WorkStealingQueue`的[steal](https://github.com/apache/brpc/blob/master/src/bthread/work_stealing_queue.h#L117)函数,使一次可以获取多一些任务,任务数量为
`min(MAX_STEAL_SIZE, queue_size/4)`
- 我测试的条件设置了`MAX_STEAL_SIZE=8`
**Additional context/screenshots (更多上下文/截图)**
因为限制了只有剩余任务大于8个才会steal超过1个的任务,在CPU不高的时候任务等待时间也不会比之前的版本差
希望可以考虑测试调整这部分的调度逻辑,谢谢
Contributor guide
Research direction
Start with the WorkStealingQueue::steal function in src/bthread/work_stealing_queue.h at the linked location, then trace how task stealing is used by the bthread scheduler. The change is complete when stealing can take up to min(MAX_STEAL_SIZE, queue_size/4) tasks while preserving correct queue behavior; evaluate the scheduling and performance impact under frequent task creation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- performance
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100