Saturday, 15 September 2012

python - Parallel processing through 1 program or different files -



python - Parallel processing through 1 program or different files -

i have python programme in need run particular function different parameter values.

so increment cpu usage, tried 2 different methods,

i created many copies of file , ran each each 1 on separate terminals. ( cpu usage : 30 % 1 file . cpu usage 3 files = 90% )

i used library multithreading , created many threads no of cores on test machine. ( cpu usage : 33 % only.) tried increasing no. of threads performance did not increase.

can tell perchance wrong in 2nd method?

it's because of global interpreter lock (gil). it's global lock locking whole memory prevent multiple threads accesing @ same time. it's not feature of python itself, of cpython, default python implementation. see link @ start of answer.

to utilize cores, @ multiprocessing module creates different processes running in different pythons, hence not needing gil.

python multithreading cpu-usage

No comments:

Post a Comment