gpt4 book ai didi

java - 并行化异构任务的局限性

转载 作者:行者123 更新时间:2023-11-30 08:08:25 25 4
gpt4 key购买 nike

我在阅读 Java Concurrency in Practice 时看到一段话是这样说的:-

Under 6.3.4 Limitations of parallelizing heterogeneous tasks

A further problem with dividing heterogeneous tasks among multiple workersis that the tasks may have disparate sizes. If you divide tasks A and B betweentwo workers but A takes ten times as long as B, you’ve only speeded up the totalprocess by 9%. Finally, dividing a task among multiple workers always involvessome amount of coordination overhead; for the division to be worthwhile, thisoverhead must be more than compensated by productivity improvements due toparallelism.

现在,如果您仔细阅读粗体部分,是否正确地说工作线程的协调开销必须超过我使用线程并行性实现的性能提升?

有人能帮我理解一下吗?

最佳答案

不,粗体部分显着改变了句子的意思:

Finally, dividing a task among multiple workers always involves some amount of coordination overhead; for the division to be worthwhile, this overhead must be more than compensated by productivity improvements due to parallelism.

如果这只是“必须不仅仅是生产力的提高......”那么你是对的。上面所说的是,通过在工作线程之间分配任务(开销)而招致的性能损失必须小于这样做所获得的性能提升。

例如,如果您的开销为 10 秒而性能提升仅为 5 秒,那么并行化操作实际上降低了您的整体性能。如果您的开销为 10 秒,但性能提升为 50 秒,则最终总执行时间减少了 40 秒(即改进)。

另一种说法是“......这种开销必须被并行性带来的生产力提高所抵消。”。

关于java - 并行化异构任务的局限性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33143229/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com