multiprocessing vs thread performance

mk mrkafk at gmail.com
Mon Dec 29 10:14:14 EST 2008


janislaw wrote:

> Ah, so there are 100 processes at time. 200secs still don't sound
> strange.

I ran the PEP 371 code on my system (Linux) on Python 2.6.1:

Linux SLES (9.156.44.174) [15:18] root ~/tmp/src # ./run_benchmarks.py 
empty_func.py

Importing empty_func
Starting tests ...
non_threaded (1 iters)  0.000005 seconds
threaded (1 threads)    0.000235 seconds
processes (1 procs)     0.002607 seconds

non_threaded (2 iters)  0.000006 seconds
threaded (2 threads)    0.000461 seconds
processes (2 procs)     0.004514 seconds

non_threaded (4 iters)  0.000008 seconds
threaded (4 threads)    0.000897 seconds
processes (4 procs)     0.008557 seconds

non_threaded (8 iters)  0.000010 seconds
threaded (8 threads)    0.001821 seconds
processes (8 procs)     0.016950 seconds

This is very different from PEP 371. It appears that the PEP 371 code 
was written on Mac OS X. The conclusion I get from comparing above costs 
sis that OS X must have very low cost of creating the process, at least 
when compared to Linux, not that multiprocessing is a viable alternative 
to thread / threading module. :-(




More information about the Python-list mailing list