testing python multiprocessing: low speed because of overhead?

后端 未结 1 1377
终归单人心
终归单人心 2021-01-14 02:51

I\'m trying to learn about multiprocessing in python (2.7). My CPU has 4 cores. In the following code I test speed of parallel Vs serial execution of the same b

相关标签:
1条回答
  • 2021-01-14 03:28

    Yes, this may be related to overhead, including:

    • Creating and starting the processes
    • passing the function and the arguments over to them
    • waiting for process termination

    If you truly have 4 physical cores on your machine (and not 2 cores with hyperthreading or similar), you should see that the ratio becomes closer to what is expected for larger inputs, as chepner said. If you only have 2 physical cores, you can't get ratio < 0.5

    0 讨论(0)
提交回复
热议问题