Best processor (i386) for Python performance?
Dave Brueck
dave at pythonapocrypha.com
Thu Aug 26 11:49:22 EDT 2004
Grant Edwards wrote:
> On 2004-08-26, Brett C. <brett at python.org> wrote:
>
>
>>In terms of multithreading, an I/O intensive app that is
>>threaded can make use of dual procs. Otherwise threaded apps
>>can't for technical reasons (GIL and such but don't need to
>>get into those details).
>
>
> That's rather dissappointing. If I write a multi-threaded app
> in C it can utilize multiple processors, but the same app in
> Python can't?
Depends on what the multithreaded app _does_. If multiple processors are
present then Python will use them, but how well they get used depends on
how much and for what reasons the GIL gets released.
I/O is the most common reason, so adding another processor to an I/O
bound program can give you a good performance boost (in our lab I've
seen easily 75% improvement over a single proc box for a program that
was very I/O bound, but I haven't measured it to see if it's closer to
75% or to 100% improvement).
Another easy boost comes if your app already calls out to a
GIL-releasing C function for CPU-intensive work, then adding a CPU can
give similar speed boosts - we have only one such case and although
there was noticable speedup in dual vs single processors, I never
attempted to quantify it. And the normal restrictions on parallel
computing apply - if whatever you're doing can't be done in parallel
anyway, then adding a CPU isn't helpful. :)
FWIW I haven't noticed a case where adding a CPU improved performance by
*less* than ~25%, probably because the GIL gets released here and there
for various operations anyway, and having an existing multithreaded app
where multiple threads are CPU bound is somewhat uncommon.
But then again very few of the projects I work on end up having CPU as
the most scarce resource so the machines that do have multiple CPUs are
that way because they are running oodles of other processes as well.
-Dave
More information about the Python-list
mailing list