You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pylucene-dev@lucene.apache.org by Bill Janssen <ja...@parc.com> on 2010/03/05 22:48:48 UTC
the Python multicore threading problem & jcc?
The problem Python has with multiple cores and multi-threading, pointed
out by Dave Beazley last year (http://www.dabeaz.com/python/GIL.pdf),
looks like it will still persist for the next three or four years, at
least, on OS X. Incredible but true. I'm presuming that PyLucene also
suffers from it, though the interaction with Java threads makes me
wonder a bit.
Anyone know whether this is so?
And, a follow-up question: if one were to build a version of Python 2.6
with the "newgil" patch in http://bugs.python.org/issue7753 applied,
would it break jcc?
Bill
Re: the Python multicore threading problem & jcc?
Posted by Roman Chyla <ro...@gmail.com>.
I have actually used one java library in python multithread. Ie the
java call timedout and i tried to create a new instance (the timeout
was not properly implemented and java was still running). So i created
new instance and saw two instances of java object taking both cpus. I
thought it is a nice side effect. I havent done anything with it (it
was a mistake) but worth trying. In this case gil is actually a
benefit. Right?
On 3/6/10, Bill Janssen <ja...@parc.com> wrote:
> Andi Vajda <va...@apache.org> wrote:
>
>>
>> On Mar 5, 2010, at 13:48, Bill Janssen <ja...@parc.com> wrote:
>>
>> > The problem Python has with multiple cores and multi-threading,
>> > pointed
>> > out by Dave Beazley last year (http://www.dabeaz.com/python/GIL.pdf),
>> > looks like it will still persist for the next three or four years, at
>> > least, on OS X. Incredible but true. I'm presuming that PyLucene
>> > also
>> > suffers from it, though the interaction with Java threads makes me
>> > wonder a bit.
>> >
>> > Anyone know whether this is so?
>>
>> Any thread that enters java releases the GIL. When the execution
>> returns (or enters) python again, the GIL is reacquired.
>>
>> In other words, the answer to your question depends on how much time
>> your threads are spending in the JVM.
>
> So, yes, that Python will still suffer from the issue if it has lots of
> CPU-bound threads fighting to get scheduled, but time spent in the JVM
> counts as I/O time, not computation time. OK, that's useful.
>
>> > And, a follow-up question: if one were to build a version of Python
>> > 2.6
>> > with the "newgil" patch in http://bugs.python.org/issue7753 applied,
>> > would it break jcc?
>>
>> If the GIL and threading APIs didn't change I wouldn't expect any
>> issues.
>
> The whole point of that patch is to backport Antoine Pitrou's new GIL
> from Python 3.2 to Python 2.5 - 2.7. See
> http://www.dabeaz.com/python/NewGIL.pdf for an overview. So the GIL
> changes. But perhaps not in a way that affects jcc.
>
> Bill
>
--
Sent from Gmail for mobile | mobile.google.com
Re: the Python multicore threading problem & jcc?
Posted by Bill Janssen <ja...@parc.com>.
Andi Vajda <va...@apache.org> wrote:
>
> On Mar 5, 2010, at 13:48, Bill Janssen <ja...@parc.com> wrote:
>
> > The problem Python has with multiple cores and multi-threading,
> > pointed
> > out by Dave Beazley last year (http://www.dabeaz.com/python/GIL.pdf),
> > looks like it will still persist for the next three or four years, at
> > least, on OS X. Incredible but true. I'm presuming that PyLucene
> > also
> > suffers from it, though the interaction with Java threads makes me
> > wonder a bit.
> >
> > Anyone know whether this is so?
>
> Any thread that enters java releases the GIL. When the execution
> returns (or enters) python again, the GIL is reacquired.
>
> In other words, the answer to your question depends on how much time
> your threads are spending in the JVM.
So, yes, that Python will still suffer from the issue if it has lots of
CPU-bound threads fighting to get scheduled, but time spent in the JVM
counts as I/O time, not computation time. OK, that's useful.
> > And, a follow-up question: if one were to build a version of Python
> > 2.6
> > with the "newgil" patch in http://bugs.python.org/issue7753 applied,
> > would it break jcc?
>
> If the GIL and threading APIs didn't change I wouldn't expect any
> issues.
The whole point of that patch is to backport Antoine Pitrou's new GIL
from Python 3.2 to Python 2.5 - 2.7. See
http://www.dabeaz.com/python/NewGIL.pdf for an overview. So the GIL
changes. But perhaps not in a way that affects jcc.
Bill
Re: the Python multicore threading problem & jcc?
Posted by Andi Vajda <va...@apache.org>.
On Mar 5, 2010, at 13:48, Bill Janssen <ja...@parc.com> wrote:
> The problem Python has with multiple cores and multi-threading,
> pointed
> out by Dave Beazley last year (http://www.dabeaz.com/python/GIL.pdf),
> looks like it will still persist for the next three or four years, at
> least, on OS X. Incredible but true. I'm presuming that PyLucene
> also
> suffers from it, though the interaction with Java threads makes me
> wonder a bit.
>
> Anyone know whether this is so?
Any thread that enters java releases the GIL. When the execution
returns (or enters) python again, the GIL is reacquired.
In other words, the answer to your question depends on how much time
your threads are spending in the JVM.
> And, a follow-up question: if one were to build a version of Python
> 2.6
> with the "newgil" patch in http://bugs.python.org/issue7753 applied,
> would it break jcc?
If the GIL and threading APIs didn't change I wouldn't expect any
issues.
Andi..
>
> Bill