Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #6057

Re: Multiprocessing: don't push the pedal to the metal?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <awilliam@whitemice.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'concurrent': 0.04; '(unless': 0.09; 'etc...': 0.09; 'spawn': 0.09; 'subject:don': 0.09; 'values,': 0.09; 'am,': 0.14; 'wrote:': 0.14; 'angelico': 0.16; 'benefit.': 0.16; 'cache.': 0.16; 'from:addr:awilliam': 0.16; 'from:addr:whitemice.org': 0.16; 'from:name:adam tauno williams': 0.16; 'message-id:@linux-yu4c.site': 0.16; 'received:72.14.190': 0.16; 'received:72.14.190.87': 0.16; 'received:mail.wmmi.net': 0.16; 'received:wmmi.net': 0.16; 'reply- to:addr:awilliam': 0.16; 'reply-to:addr:whitemice.org': 0.16; "there'll": 0.16; 'cache': 0.16; 'mon,': 0.17; 'issue,': 0.19; 'model,': 0.19; 'programming': 0.19; 'header:In-Reply-To:1': 0.21; "haven't": 0.22; 'issues.': 0.23; 'platforms,': 0.23; 'load': 0.24; '(or': 0.24; 'posted': 0.25; 'monitor': 0.26; 'received:72.14': 0.26; 'correct': 0.28; 'subject:?': 0.29; "python's": 0.29; 'all,': 0.30; 'fact': 0.30; 'parent': 0.30; 'worker': 0.30; 'anyone': 0.32; 'done': 0.32; 'app': 0.32; 'execution': 0.32; 'value.': 0.32; 'to:addr:python-list': 0.33; 'too': 0.33; "i've": 0.33; 'chris': 0.34; 'core': 0.35; 'there': 0.35; 'else': 0.35; 'certain': 0.36; 'setting': 0.36; 'uses': 0.36; 'running': 0.37; 'rules': 0.37; 'too.': 0.37; 'thread': 0.37; 'but': 0.38; 'subject:: ': 0.38; 'some': 0.38; "i'd": 0.39; 'itself.': 0.39; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'best,': 0.60; 'more': 0.60; 'your': 0.60; 'below': 0.61; 'john': 0.62; 'back': 0.63; 'benefit': 0.70; 'hearing': 0.71; 'header:Reply-To:1': 0.72; 'reply-to:no real name:2**0': 0.72; 'average': 0.77; 'anywhere.': 0.84; 'python-': 0.84; 'undoubtedly': 0.84; '10:32': 0.91; 'master,': 0.91
Subject Re: Multiprocessing: don't push the pedal to the metal?
From Adam Tauno Williams <awilliam@whitemice.org>
To python-list@python.org
In-Reply-To <BANLkTi=AEW6TLwqcUmbiQ+NL8m9UDqhVLA@mail.gmail.com>
References <644e4768-0fee-4c40-ba59-4b777b883884@z13g2000prk.googlegroups.com> <0211797f-e130-4bfa-bcb0-f701ec33c7b9@17g2000prr.googlegroups.com> <BANLkTi=AEW6TLwqcUmbiQ+NL8m9UDqhVLA@mail.gmail.com>
Content-Type text/plain; charset="UTF-8"
Date Mon, 23 May 2011 05:50:31 -0400
Mime-Version 1.0
X-Mailer Evolution 2.32.1
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
Reply-To awilliam@whitemice.org
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1967.1306145336.9059.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 82.94.164.166
X-Trace 1306145336 news.xs4all.nl 49179 [::ffff:82.94.164.166]:34429
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:6057

Show key headers only | View raw


On Mon, 2011-05-23 at 10:32 +1000, Chris Angelico wrote:
> On Mon, May 23, 2011 at 7:06 AM, John Ladasky <ladasky@my-deja.com> wrote:
> > If I spawn N worker sub-processes, my application in fact has N+1
> > processes in all, because there's also the master process itself.
> > I'd still appreciate hearing from anyone else who has more experience
> > with multiprocessing.  If there are general rules about how to do this
> > best, I haven't seen them posted anywhere.  This may not be a Python-
> > specific issue, of course.
> I don't have much experience with Python's multiprocessing model, but
> I've done concurrent programming on a variety of platforms, and there
> are some common issues.

I develop an app that uses multiprocessing heavily.  Remember that all
these processes are processes - so you can use all the OS facilities
regarding processes on them.  This includes setting nice values,
schedular options, CPU pinning, etc...

> Each CPU (or core) has its own execution cache. If you can keep one
> thread running on the same core all the time, it will benefit more
> from that cache than if it has to keep flitting from one to another.

+1

> You undoubtedly will have other processes in the system, too. As well
> as your master, there'll be processes over which you have no control
> (unless you're on a bare-bones system). Some of them may preempt your
> processes.

This is very true.  You get a benefit from dividing work up to the
correct number of processes - but too many processes will quickly take
back all the benefit.  One good trick is to have the parent monitor the
load average and only spawn additional workers when that value is below
a certain value.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Multiprocessing: don't push the pedal to the metal? John Ladasky <ladasky@my-deja.com> - 2011-05-21 20:58 -0700
  Re: Multiprocessing: don't push the pedal to the metal? John Ladasky <ladasky@my-deja.com> - 2011-05-22 14:06 -0700
    Re: Multiprocessing: don't push the pedal to the metal? Chris Angelico <rosuav@gmail.com> - 2011-05-23 10:32 +1000
    Re: Multiprocessing: don't push the pedal to the metal? Adam Tauno Williams <awilliam@whitemice.org> - 2011-05-23 05:50 -0400
      Re: Multiprocessing: don't push the pedal to the metal? John Ladasky <ladasky@my-deja.com> - 2011-05-23 12:51 -0700
        Re: Multiprocessing: don't push the pedal to the metal? Adam Tauno Williams <awilliam@whitemice.org> - 2011-05-23 16:46 -0400

csiph-web