Earlier quoted context omitted.
Python's "multiprocessing" means launching another Python interpreter in a subprocess. Each process has a full copy of the Python environment. They may share the base interpreter, but there's a separate copy of every package loaded and all data. Memory consumption is bloated and the CPU caches thrash. Launching a subprocess is expensive; it means a full interpreter launch and a recompile/reload. "Multiprocessing" is…
If CPU load is an issue, why would you be using an interpreter in the first place?
Let's Remove the Global Interpreter Lock
191–200 of 326 posts
Re: Let's Remove the Global Interpreter Lock
#192Earlier quoted context omitted.
Except when your use case requires a massive shared data cache that needs to be atomically updated.
Redis could help. Obviously not perfect for every use case but covers many of them.
Also, you're describing multiple python processes + an extra server (redis) process - as a "simpler" solution for the limitation that Python doesn't do multi-threads well.
Of course there are a ton of use cases out there where you can scale in other ways, but threads and shared memory exist for a reason - there's no reason not to call a spade a spade and say the GIL is still a limitation.
Re: Let's Remove the Global Interpreter Lock
#1931. People like to talk about it a lot, complain about it and say their opinion of what should be done with it.
2. It's not likely to be resolved for years to come.
3. In the end, the problem has very little effect on people's lives, much much less than the amount of hype around the issue.
Re: Let's Remove the Global Interpreter Lock
#194Earlier quoted context omitted.
Python's "multiprocessing" means launching another Python interpreter in a subprocess. Each process has a full copy of the Python environment. They may share the base interpreter, but there's a separate copy of every package loaded and all data. Memory consumption is bloated and the CPU caches thrash. Launching a subprocess is expensive; it means a full interpreter launch and a recompile/reload. "Multiprocessing" is…
If CPU load is an issue, why would you be using an interpreter in the first place?
Re: Let's Remove the Global Interpreter Lock
#195Earlier quoted context omitted.
Except when your use case requires a massive shared data cache that needs to be atomically updated.
I think it's ok to not write everything in Python, and this is a long way from the top of my problems with it.
Re: Let's Remove the Global Interpreter Lock
#196Earlier quoted context omitted.
With threading, all of your threads can refer to the same objects. Multiprocessing means you have multiple interpreters running. That means no shared memory, and communication over pretty slow queues. I've definitely wanted to have multithreaded Python programs where all threads referred to the same large read-only data structure. But I can't do this because of the GIL. I mean, I can, but it's pointless. I can't do t…
Yeah, sharing memory between processes is a very delicate ballet to perform. That said, sharing a read-only piece of data is way simpler than you'd expect, depending on size and your forking chain. The documentation could do a better job of explaining the nuances and provide more examples.
Re: Let's Remove the Global Interpreter Lock
#197Earlier quoted context omitted.
C API... You can argue it's not a part of the language, but PyPy was forced to support it at the end
IronPython interoperates with a whole host of C and C++ code. I'm not sure why this would matter? The initial implementation may need to assume single-threaded C interface support and take a global lock but it wouldn't be a stretch to have these things declare they are multithread aware and relax that restriction. Forgive me but most of these objections seem like post-hoc rationalizations. The first step is deciding…
Re: Let's Remove the Global Interpreter Lock
#198Re: Let's Remove the Global Interpreter Lock
#199Re: Let's Remove the Global Interpreter Lock
#200Earlier quoted context omitted.
Certainly! It's a bit hard to answer some of those questions because it's been so long since we've run CPython, and also because we've now got ~10 apps or so that run on PyPy. Initially memory tradeoff was definitely significant, somewhere around 40% or so -- it's going to vary across applications though certainly, and in a lot of cases I'm a bit happy our memory usage went up because it forces us more towards "nicer…
are you using any math packages like Numpy/Pandas or Opencv ?
They do work these days in PyPy though, so I'd feel comfortable doing so if we did, although I'd probably feel just as comfortable writing whatever numerics in pure-Python too unless it was stuff that already existed easily elsewhere.
On a personal note I've played with OpenCV as well (and done so with PyPy to do some real-time facial analysis on a video stream), but yeah also not for $PRODUCTION_WORK.