Multiprocessing : More processes than cpu.count

前端 未结 1 508
忘掉有多难
忘掉有多难 2020-12-31 01:03

Note: I \"forayed\" into the land of multiprocessing 2 days ago. So my understanding is very basic.

I am writing and application for up

相关标签:
1条回答
  • 2020-12-31 01:21

    The number of processes running concurrently on your computer is not limited by the number of cores. In fact you probably have hundreds of programs running right now on your computer - each with its own process. To make it work the OS assigns one of your 8 processors to each process or thread only temporarily - at some point it may get stopped and another process will take its place. See What is the difference between concurrent programming and parallel programming? if you want to find out more.

    Edit: Assigning more processes in your uploading example may or may not make sense. Reading from disk and sending over the network is normally a blocking operation in python. A process that waits for its chunk of data to be read or sent can be halted so that another process may start its IO. On the other hand, with too many processes either file I/O or network I/O will become a bottleneck and your program will slow down because of the additional overhead needed for process switching.

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