thread_migrate strategy changes from random to round-robin #163
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
thread_migrate原先随机的策略有一个缺陷:当thread数量小于vcpu数量时,有一定的概率会产生多个thread堆积到某一个相同的vcpu上的情况。由于我们的thread迁移是被动的,因此一直也无法迁走。这样造成OS线程空闲,workload不均衡。
因此把random改成了round-robin。参考了没有work stealing机制的其他的库,比如cocoyaxi,用的也是rr。
The original random strategy of thread_migrate has a defect: when the number of threads is less than the number of vcpus, there is a certain probability that multiple threads will be scheduled to the same vcpu. Since our thread migration is passive, it's not likely to migrate away in the future. So this causes idle OS threads and unbalanced workload.
So changed the strategy from random to round-robin. Have referred to other libraries that have no work stealing mechanism, such as cocoyaxi. They are using rr as well.