Multi-threading on Multi-CPU machines

Garry Taylor gtaylor at lowebroadway.com
Wed Jul 10 05:59:52 EDT 2002


aahz at pythoncraft.com (Aahz) wrote in message news:<agdnu9$cne$1 at panix1.panix.com>...
> In article <f0fd5987.0207080702.407100ec at posting.google.com>,
> Garry Taylor <gtaylor at lowebroadway.com> wrote:
> >
> >I am attempting to make a multi-threading function in one of my
> >programs in an effort to gain a speed increase, but I'm getting quite
> >the opposite, even on a dual-CPU Intel/Linux box. Can anyone enlighten
> >me as to why, my code is below:
> 
> Pure Python code will always slow down when threaded; in order to gain a
> speedup, you must call an extension that releases the GIL.  All I/O
> functions in Python release the GIL, for example.  For more info, see
> the slides on my home page.

Thanks to those who replied, I think releasing the GIL would appear to
be my best bet, as I don't want to add yet another dependency to the
program, i.e. MPI and PyPar, also by 'Shared Memory' I take it you
mean NUMAFlex machines and similar rather than a little 2x1GHz P4 Dell
Server?

The kind of machines my program will run on will max out at 4 way, I
would expect, and it's not math-intensive or anything, I just want to
speed up fairly average tasks, which only take around 10 seconds on a
single processor.

Thanks again

Garry



More information about the Python-list mailing list