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

标签 java multithreading parallel-processing

我正在阅读《Java 并发实践》,其中有一段内容是这样的:-

Under 6.3.4 Limitations of parallelizing heterogeneous tasks

A further problem with dividing heterogeneous tasks among multiple workers is that the tasks may have disparate sizes. If you divide tasks A and B between two workers but A takes ten times as long as B, you’ve only speeded up the total process by 9%. 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.

现在,如果您仔细阅读粗体部分,那么工作线程的协调开销必须大于我使用线程并行性实现的性能改进是否正确?

有人可以帮我理解一下吗?

最佳答案

不,粗体部分显着改变了句子的含义:

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/

相关文章:

java - 从 "Filthy Rich Clients"开始理解Swing代码

java - 线程ID=1 : thread exiting with uncaught exception (group=0x41cd1700)

parallel-processing - pymongo - 执行并行查询

multithreading - atomic.Load 和atomic.Store 的意义是什么

Java顺序实现比并行实现快4倍

java - 如何组合对象项并求和数量 - JAVA

java - 如何使用 Java 获取 XML id 值?

java - 通过 Web 服务公开网站

windows - 对于在 Windows 上运行的未阻塞线程等待执行,16 毫秒是否异常长?

java - ScheduledExecutorService Thread 创建多个线程