Earlier quoted context omitted.
You do not need threads for shared memory. I know of quite a few high-performance software systems that use process isolation and yet leverage shared memory via mechanisms like mmap() for IPC.
Good point, but shared memory via mmap isn't very Pythonic since you have to manage the shared memory manually, you can't allocate Python objects on the shared region, etc.
First Python 2.7 interpreter to use multiple cores
21–30 of 42 posts
Re: First Python 2.7 interpreter to use multiple cores
#22I'm not following this. Does it mean the GIL is finally gone?
I will get excited when it actually works out to be faster than interpreters with the GIL. I'm a bit disappointed that Python seems to have no interest in standardizing a lightweight-thread (greenlet, coroutine) interface that isn't an awful mess. yield is powerful but coroutine implementations with it are baroque and opaque. Java-style threading has a million gotchas and the interface is just a dog. I want to be abl…
If it's within 5% though, I'll be happy - especially if the backend is possible to switch. It seems that it's possible now - so if you know you're running only in a single thread you could just choose the cut-down version.
Re: First Python 2.7 interpreter to use multiple cores
#23^^^^^maybe tell us again when its not thanks!
Re: First Python 2.7 interpreter to use multiple cores
#24To be a bit pedantic: the multiprocess module works fine for multiple cores in regular cpython, I actually used it for a little graphics program I wrote. Nice to see the GIL gone for multithreading though :)
Re: First Python 2.7 interpreter to use multiple cores
#25Given that, and given that the patches for removing the GIL were submitted for an earlier version a while back (2.4 or before, I believe), is it unfeasible/impossible to design an interpreter that detects whether a program requires support for multiple threads and then act accordingly? Since this currently requires the inclusion of a module, it seems like it would be unambiguous.
Re: First Python 2.7 interpreter to use multiple cores
#26But I think it's a slight oversell to call this a python 2.7 interpreter. For instance, most scientific computing code that runs in cpython 2.7 won't run on pypy.
It's impressive from a computer science point of view. But, pypy has a ways to go before I'd call it a python interpreter without adding qualifications.
Re: First Python 2.7 interpreter to use multiple cores
#27My understanding of the GIL is that its inclusion was justified by the fact that removing it would speed up multithreaded programs at the cost of slowing down single-threaded programs (the latter being more common than the former). Given that, and given that the patches for removing the GIL were submitted for an earlier version a while back (2.4 or before, I believe), is it unfeasible/impossible to design an interpre…
Re: First Python 2.7 interpreter to use multiple cores
#28My understanding of the GIL is that its inclusion was justified by the fact that removing it would speed up multithreaded programs at the cost of slowing down single-threaded programs (the latter being more common than the former). Given that, and given that the patches for removing the GIL were submitted for an earlier version a while back (2.4 or before, I believe), is it unfeasible/impossible to design an interpre…
Detection will be non-trivial. On the other hand, it could be a simple command line option, like specifying the number of cores you want your program to run on.
Of course, the slow path would just use STM all the time.
Re: First Python 2.7 interpreter to use multiple cores
#29To be a bit pedantic: the multiprocess module works fine for multiple cores in regular cpython, I actually used it for a little graphics program I wrote. Nice to see the GIL gone for multithreading though :)
To be even more pedantic, python already runs on multiple cores. They poll the GIL until they can run. I believe some version of Python 3 fixes this behavior so they don't have to poll the GIL.
The GIL is released during the execution of some C code, so another thread may execute Python code in the meantime, but that's probably besides the point too.
Re: First Python 2.7 interpreter to use multiple cores
#30Earlier quoted context omitted.
Detection will be non-trivial. On the other hand, it could be a simple command line option, like specifying the number of cores you want your program to run on.
I'm not sure about that. If you hook thread creation into invalidating the code that was was JITted without STM, you might be able to handle it reasonably well. Of course, the slow path would just use STM all the time.
I mean, that is non-trivial.