This experiment was run on Linux-4.9.125-linuxkit-x86_64-with-Ubuntu-18.04-bionic (indeed, in a docker Virtual Machine) with Python 3.6.8, the system had 4 physical cores with 4 hyperthreads, thus 8 logical cores.
An incorrect way to do:
1 |
|
The output was
1 |
|
By doing so, only 1 core among 8 cores was used at 100%, whereas other 7 cores were almost at 0% (checked by linux command top
). At a given time, only 100% (instead of 800%) of CPU charge was used, even though this 100% CPU charge may move from one core to another every time a new process started.
The correct way to do:
1 |
|
The output of the correct way was:
1 |
|
By using the correct way, all 8 cores were used at 100% (checked by linux command top
).
The difference is the following:
1 |
|
becomes
1 |
|