Threadpool program runs much slower on much faster server

帅比萌擦擦* 提交于 2019-11-30 07:37:20

just because you have a System which can handle much more threads, this does not mean that all of them can be fully processed parallel.

When I upgrade from a Quadcore CPU to a i7(virtual 8 cores), I noticed that a setup using more threads than cores resulted in the threads blocking each other for some time, which lead to an overall slowdown of the System.

The problem was just that my algorythims already were capable of using the full processing time of the core their thread was running on while waiting threads only worked on about 5 to 10%, which lead to the main threads to finish but some singe threads still having to do all their work(taking the same amout of time again).

The threadpool will only continue if all workers have finished, so the total amount of time until finishing will be unuset processor time for the other threads.

maybe you just need to find an optimal number of threads.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!