overhead of starting threads

Will McGugan news at NOwillmcguganSPAM.com
Mon May 23 17:07:17 EDT 2005


Simon Percivall wrote:
> How much you gain by starting threads is also determined by what you're
> doing in those threads. Remember (or learn): In CPython only one thread
> at a time can execute python code, so depending on your task threading
> might gain you little. If you're doing I/O or calling functions written
> in C (and if they release the Global Intepreter Lock [GIL]) you might
> gain a lot by using threads.

I wasn't asking about wether to use threads or not, I already am - for 
several long running partialy I/O bound tasks.

> 
> As for overhead: profile, profile, profile. You'll have to do sample
> runs and find your sweet-spot. It all depends on what you're doing in
> the threads.
> 

I haven't had much luck with the profile module in the standard library. 
  It only shows me data from the main thread. Is there a better way of 
profile heavily threaded code?


Will McGugan

-- 
http://www.willmcgugan.com
"".join( [ {'*':'@','^':'.'}.get(c,None) or chr(97+(ord(c)-84)%26) for c 
in "jvyy*jvyyzpthtna^pbz" ] )



More information about the Python-list mailing list