Threading advantages (was Re: Python's biggest compromises)

Aahz aahz at pythoncraft.com
Wed Aug 6 20:02:21 EDT 2003


In article <ad02da8c.0308061409.3aeb22a3 at posting.google.com>,
enoch <enoch at gmx.net> wrote:
>aahz at pythoncraft.com (Aahz) wrote in message news:<bgr96h$a9$1 at panix3.panix.com>...
>> In article <ad02da8c.0308060705.7ff1fa4f at posting.google.com>,
>> enoch <enoch at gmx.net> wrote:
>>>anthony_barker at hotmail.com (Anthony_Barker) wrote in message news:<899f842.0307310555.56134f71 at posting.google.com>...
>>>> 
>>>> What to you think python largest compromises are?
>>>
>>>Its non existant SMP scalability.
>> 
>> Would you care to back up your claim with some actual evidence?
>> 
>> (Yes, there are issues with Python on SMP machines, but to call Python's
>> built-in threading "non-existent SMP scalability" is either a lie or
>> revelatory of near-complete ignorance.  
>
>Ok, I confess, the term you cited might be little bit exaggerated. But
>there's no need to get personal. I'm surely not a liar (w.r.t. to this
>thread, everything else is not a matter of public concern ;) ). The
>ignorance part, well, we can talk about that ...

Since, as you say, you've done some research, that's why I flamed you.
There's just no call for making such an overstated claim -- it is *NOT*
"a little bit exaggerated".

>> That doesn't even count the various IPC mechanisms.)
>
>Correct me if I'm wrong, but I don't think any form of IPC is a
>measurement of scalability of something like the python interpreter.

Depends what your context is.  If you're restricting yourself to
discussing the Python interpreter, that's correct; if you're discussing
ways to boost the performance of a Python application on an SMP box,
it's entirely appropriate.

>Here are some sources which show that I'm not alone with my assessment
>that python has deficiencies w.r.t. SMP systems:

That I won't argue.  But Python's approach also has some benefits even
on SMP systems.  And if you choose a multi-process approach, the same
advantages that accrue to Python's approach on a single-CPU box apply
just as much to an SMP system.

>http://www.python.org/pycon/papers/deferex/
>"""
>It is optimal, however, to avoid requiring threads for any part of a
>framework. Threading has a significant cost, especially in Python. The
>global interpreter lock destroys any performance benefit that
>threading may yield on SMP systems, [...]
>"""

Just because it's a published PyCon paper doesn't mean that it's correct.
The multi-threaded spider that I use as my example is a toy version of a
spider that was used on an SMP box.  (That's why I became a threading
expert in the first place -- Tim Peters probably remembers me pestering
him with questions four years ago. ;-)  I guarantee you that SMP made
that spider much faster.

>So, although python is capable of taking advantage of SMP systems
>under certain circumstances (I/O bound systems etc. etc.), there are
>real world situations where python's performance is _hurt_ by running
>on a SMP system.

Absolutely.  But that's true of any system with threading that isn't
designed and tuned for the needs of a specific application.  Python
trades performance in some situations for a clean and simple model of
threading.

>Btw. I think even IPC might not help you there, because the different
>processes might bounce betweeen CPUs, so only processor binding might
>help.

My understanding that most OSes are designed to avoid this; I'd be
interested in seeing some information if I'm wrong.  In any event, I do
know that IPC speeds things up in real-world applications on SMP boxes.

>I did quite a bit of googling on this problem - several times -
>because I'm selling zope solutions. Sometimes, the client wants to run
>the solution on an existing SMP system, and worse, the system has to
>fulfill some performance requirements. Then I have the problem of
>explaining to him that his admins need to undertake some special tasks
>in order for zope to be able to exploit the multiple procs in his
>system.

Even if Zope is the 800-pound gorilla of the Python world, Python isn't
going to change just for Zope.  If you want to talk about ways of
improving Zope's performance on SMP boxes, I'll be glad to contribute
what I can.  But spreading false information isn't the way to get me
interested.

Keep in mind that one reason IPC has gained popularity is because it
scales more than threading does, in the end.  Blade servers are cheaper
than big SMP boxes, and IPC works across multiple computers.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

This is Python.  We don't care much about theory, except where it intersects 
with useful practice.  --Aahz




More information about the Python-list mailing list