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


Groups > comp.lang.python > #3401

Re: Questions about GIL and web services from a n00b

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <hobson42@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'context': 0.04; 'startup': 0.04; 'thread,': 0.04; 'core,': 0.07; 'cpython': 0.07; 'python': 0.07; 'concurrency': 0.09; 'received:81.103': 0.09; 'received:81.103.221': 0.09; 'received:81.103.221.35': 0.09; 'received:ispmail.ntl.com': 0.09; 'received:ntl.com': 0.09; 'run.': 0.09; 'essentially': 0.12; 'am,': 0.14; 'extension': 0.14; 'wrote:': 0.14; '3.2,': 0.16; 'core.': 0.16; 'cores': 0.16; 'cpython,': 0.16; 'from:addr:hobson42': 0.16; 'from:name:ian': 0.16; 'gil.': 0.16; 'ironpython,': 0.16; 'received:192.168.0.12': 0.16; 'received:aamtaout02-winn.ispmail.ntl.com': 0.16; 'reply- to:addr:hobson42': 0.16; 'subject:GIL': 0.16; 'switching': 0.16; 'threading': 0.16; 'happening': 0.19; 'subject:Questions': 0.19; 'seems': 0.21; 'header:In-Reply-To:1': 0.22; 'gil': 0.23; 'issues.': 0.23; 'locking': 0.23; 'topic.': 0.23; 'runs': 0.24; "what's": 0.24; 'tests': 0.26; 'chris': 0.27; 'google': 0.27; 'load': 0.28; 'closing': 0.29; 'fri,': 0.29; 'are.': 0.29; 'bound': 0.29; 'good.': 0.29; 'indicated': 0.29; 'message- id:@gmail.com': 0.30; '(the': 0.30; 'yet': 0.30; 'lock': 0.31; 'stops': 0.31; 'threads': 0.31; 'second': 0.31; 'however,': 0.31; "can't": 0.31; 'called': 0.32; 'to:addr:python-list': 0.32; 'another': 0.32; "i've": 0.33; 'received:192': 0.34; 'actually': 0.34; 'starting': 0.34; 'received:192.168.0': 0.35; 'finding': 0.35; 'header:User-Agent:1': 0.35; '(my': 0.35; 'forces': 0.35; 'module.': 0.35; 'overhead': 0.35; 'priority': 0.35; 'too': 0.36; 'running': 0.36; 'received:192.168': 0.37; 'two': 0.37; 'way.': 0.37; 'issue': 0.37; 'run': 0.37; 'apr': 0.38; 'subject:web': 0.38; 'thread': 0.38; 'less': 0.38; 'pretty': 0.38; 'though': 0.38; 'not,': 0.39; 'likely': 0.39; 'to:addr:python.org': 0.39; 'how': 0.39; 'attempt': 0.40; "it's": 0.40; 'allows': 0.40; 'fact,': 0.60; 'bring': 0.62; '2011': 0.62; 'subject:about': 0.66; 'believe': 0.66; 'due': 0.67; 'articles': 0.67; 'thousands': 0.69; 'low': 0.71; 'reply-to:no real name:2**0': 0.72; 'header:Reply- To:1': 0.72; 'reply-to:addr:gmail.com': 0.78; 'cooperative': 0.91; 'subject:services': 0.93
Date Sun, 17 Apr 2011 16:15:22 +0100
From Ian <hobson42@gmail.com>
User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.15) Gecko/20110303 Lightning/1.0b2 Mnenhy/0.8.3 Thunderbird/3.1.9
MIME-Version 1.0
To python-list@python.org
Subject Re: Questions about GIL and web services from a n00b
References <4DA8734C.1080706@WindsorCircle.com> <BANLkTikP03hkFPFz6diSpDgE8hQ5ZCWE2A@mail.gmail.com>
In-Reply-To <BANLkTikP03hkFPFz6diSpDgE8hQ5ZCWE2A@mail.gmail.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Cloudmark-Analysis v=1.1 cv=R50lirqlHffDPPkwUlkuVa99MrvKdVWo//yz83qex8g= c=1 sm=0 a=0IQxgegUZKwA:10 a=xoZQEl1COPcA:10 a=nDghuxUhq_wA:10 a=hcRjaz30x_AA:10 a=d3ZwFMNkyaEA:10 a=8nJEP1OIZ-IA:10 a=Rp0d2WHKAAAA:8 a=RoUZVJNajUPgfJ0ZUH4A:9 a=VXz3jzV_EgjN98cjgNQA:7 a=wPNLvfGTeEIA:10 a=mqQ-7T2fUYQA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
Reply-To hobson42@gmail.com
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.463.1303053332.9059.python-list@python.org> (permalink)
Lines 53
NNTP-Posting-Host 82.94.164.166
X-Trace 1303053332 news.xs4all.nl 81473 [::ffff:82.94.164.166]:60393
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:3401

Show key headers only | View raw


On 15/04/2011 20:17, Dan Stromberg wrote:
> On Fri, Apr 15, 2011 at 9:33 AM, Chris H
> <chris.humphres@windsorcircle.com>  wrote:
>
>> 1. Are you sure you want to use python because threading is not good due to
>> the Global Lock (GIL)?  Is this really an issue for multi-threaded web
>> services as seems to be indicated by the articles from a Google search?  If
>> not, how do you avoid this issue in a multi-threaded process to take
>> advantage of all the CPU cores available?
> Concurrency in Python is a largish topic.
>
> It's true that CPython's multithreading is poor.  In fact, running a
> multithreaded CPython application on n vs 2n cores can actually take
> more time on the 2n cores.
>
> However:
> 1) In Jython, and likely IronPython, threading is good.
The load times of Iron Python are ssslllooooowwwww!
(My tests showed startup times 4 to 6 times that of cpython on the same 
kit).
> 3) There's something called "stackless" and (similar to stackless)
> "greenlets".  While stackless allows you to use thousands of threads
> comfortably, it's still pretty single-core.  It's essentially a fork
> of CPython, and is being made a part of PyPy.  I believe greenlets are
> an attempt to bring what's good about stackless to CPython, in the
> form of a C extension module.
Greenlets are green threads - cooperative switching all in one system 
thread
and therefore one core. Very lightweight.

> 4) I've heard that in CPython 3.2, the GIL is less troublesome, though
> I've not yet heard in what way.
Multiple threads still cannot run at the same time, however, if one 
thread runs too
long without a context switch, it relinquishes control and forces 
another thread to run.

This stops a low priority thread on one core, locking out a 
high-priority thread on
another. That this was happening is why 2 cores can be slower than one. 
(The overhead
of starting the second thread, finding it can't get the GIL and closing 
down again).

> 5) Even in CPython, I/O-bound processes are not slowed significantly
> by the GIL.  It's really CPU-bound processes that are.
Its ONLY when you have two or more CPU bound threads that you may have 
issues.

Regards

Ian

Back to comp.lang.python | Previous | NextNext in thread | Find similar


Thread

Re: Questions about GIL and web services from a n00b Ian <hobson42@gmail.com> - 2011-04-17 16:15 +0100
  Re: Questions about GIL and web services from a n00b sturlamolden <sturlamolden@yahoo.no> - 2011-04-17 08:49 -0700

csiph-web