Live data from Hacker News

Let's Remove the Global Interpreter Lock

morepypy.blogspot.com

181–190 of 326 posts

Re: Let's Remove the Global Interpreter Lock

#181
>fully working PyPy interpreter with no GIL as a release, possibly separate from the default PyPy release

I have concerns that if such functionality will not be in the main release enabled by default(and consequently don't get as much testing), it will just bitrot and in the end, will be removed.

Re: Let's Remove the Global Interpreter Lock

#183

Earlier quoted context omitted.

I agree wholeheartedly. Almost every time I hear from someone who is upset about the GIL, I find that they would be much better suited to using multiprocessing instead of multithreading. With 80% of the developers out there, they are basically assured of producing better, more stable code this way.

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

#184
post #181

>fully working PyPy interpreter with no GIL as a release, possibly separate from the default PyPy release I have concerns that if such functionality will not be in the main release enabled by default(and consequently don't get as much testing), it will just bitrot and in the end, will be removed.

They're asking for funding to spend on a risk-free attempt at GIL removal (risk-free since it won't bone PyPy mainline), if the attempt meaningfully succeeded I'd imagine their next step would be making it the default.

A fully functional PyPy that could do heavy math in multiple threads would be an amazing tool in the box, but there are plenty of risks to that (penalizing single threaded performance, for example). So this strategy makes plenty of sense to me.

They can't just do it on mainline from the outset because there are huge obstacles to overcome.. for example, that ancient foe, CPython extension interface compatibility, which assumes a single global lock covering all mutable extension data. I don't think there will ever be a way around maintaining the GIL for that, even if pure Python code can freewheel it otherwise

Re: Let's Remove the Global Interpreter Lock

#185

Earlier quoted context omitted.

Can't this already be handled by calling out to a C/C++ or FORTRAN procedure that processes the data in multiple threads? For number crunching, Python is almost exclusively used as glue.

You CAN handle it, but why should you have to? If it's possible to remove that barrier, then it absolutely should be removed. If the only answer to a problem is "use another language", then the language in question has a limitation that needs to be addressed.

It is not a limitation at all in this case. Python is just a front to Tensorflow and similar libraries/frameworks so GIL doesn't matter there.

Re: Let's Remove the Global Interpreter Lock

#186

Earlier quoted context omitted.

in what was is it a pain that threading is not?

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

#187

Earlier quoted context omitted.

Today's machine learning and data science students don't know how to code in those languages. They know python, and maybe java.

Don't forget R... shudders

What's wrong with R? I know it's not a programmers language but it's great for getting things done.

Re: Let's Remove the Global Interpreter Lock

#189
post #17

Earlier quoted context omitted.

There are many cases where the objects are too big to be passed around. Python is used a huge amount in Machine learning and datascience, where being able to do parallel work on stuff already in memory would be great.

Can't this already be handled by calling out to a C/C++ or FORTRAN procedure that processes the data in multiple threads? For number crunching, Python is almost exclusively used as glue.

[deleted]

Re: Let's Remove the Global Interpreter Lock

#190

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?

Just because those resources exist does not mean you get to park your 1997 Chevy Cavalier diagonal across three parking spaces.

I'm not going to run your code on my server if your code uses resources so poorly that I can't run other things I want to run on my server.

Post reply on HN