Live data from Hacker News

Unlocking Python's Cores:Energy Implications of Removing the GIL

arxiv.org

101–110 of 111 posts

Re: Unlocking Python's Cores:Energy Implications of Removing the GIL

#101

Earlier quoted context omitted.

Threads are cheap, you can do N work simultaneously with N threads in one process, without serialization, IPC or process creation overhead. With multiprocessing, processes are expensive and work hogs each process. You must serialize data twice for IPC, that's expensive and time consuming. You shouldn't have to break out multiple processes, for example, to do some simple pure-Python math in parallel. It doesn't make s…

It makes sense to me that a program currently written using multiple processes would now be re-written to use multiple truly parallel threads. But it seems very odd to suggest (as your grandparent comment does) that a program currently run in multiple containers would likely be migrated to run on multiple threads. In other words, I imagine anyone who cares about the overhead from serialization, IPC, or process creati…

Yeah, I somehow glossed over the whole container thing.

The container thing might be horizontal scaling thing where 1 container runs on 1 instance with 1 vCPU, running multiple processes on instances means you need beefier slices of compute to take advantage of the parallelism, and you can't cleanly scale up and then down using only the resources you need.

If you have a queue distributing work, that model makes sense with single-threaded interpreters where consumers instances are spun up and down as needed, versus pushing work to a thread pool, or multiple instances with their own thread pools, that aren't inhibited by the GIL. The latter could be more efficient depending on the work.

Re: Unlocking Python's Cores:Energy Implications of Removing the GIL

#102
post #55

Earlier quoted context omitted.

Qt costs serious money if you go commercial. That might not be important for a hobby project, but lowers the enthusiasm for using the stack since the big players won't use it unless other considerations compel them.

QT only costs money if you want access to their custom tooling or insist on static linking. We're comparing to electron here. Why do you need to static link? And why can't you write QML in your text editor of choice and get on with life?

Some widgets and modules, like Qt Charts (or Graphs, I forget), are dual GPL and commercially licensed, so it's a bit more complicated than that. You also need a commercial license for automotive and embedded deployments.

Re: Unlocking Python's Cores:Energy Implications of Removing the GIL

#103
post #48

Earlier quoted context omitted.

But python can fork itself and run multiple processes into one single container. Why would there be a need to run several containers to run several processes? There's even the multiprocessing module in the stdlib to achieve this.

Threads are cheap, you can do N work simultaneously with N threads in one process, without serialization, IPC or process creation overhead. With multiprocessing, processes are expensive and work hogs each process. You must serialize data twice for IPC, that's expensive and time consuming. You shouldn't have to break out multiple processes, for example, to do some simple pure-Python math in parallel. It doesn't make s…

But… in python threads don't run in parallel, which is the whole problem we are working around here.

Re: Unlocking Python's Cores:Energy Implications of Removing the GIL

#104

Earlier quoted context omitted.

QT only costs money if you want access to their custom tooling or insist on static linking. We're comparing to electron here. Why do you need to static link? And why can't you write QML in your text editor of choice and get on with life?

Some widgets and modules, like Qt Charts (or Graphs, I forget), are dual GPL and commercially licensed, so it's a bit more complicated than that. You also need a commercial license for automotive and embedded deployments.

Right but it's a perfectly functional (even remarkably feature complete) UI toolkit without the copyleft addons.

> You also need a commercial license for automotive and embedded deployments.

How does that work? The LGPL (really any OSI license) isn't compatible with additional usage restrictions.

Re: Unlocking Python's Cores:Energy Implications of Removing the GIL

#105
post #64

One thing I'm curious about here is the operational impact. In production systems we often see Python services scaling horizontally because of the GIL limitations. If true parallelism becomes common, it might actually reduce the number of containers/services needed for some workloads. But that also changes failure patterns — concurrency bugs, race conditions, and deadlocks might become more common in systems that wer…

> observability tooling for Python evolving As much as I dislike Java the language, this is somewhere where the difference between CPython and JVM languages (and probably BEAM too) is hugely stark. Want to know if garbage collection or memory allocation is a problem in your long running Python program? I hope you're ready to be disappointed and need to roll a lot of stuff yourself. On the JVM the tooling for all kind…

You can run Python on the JVM and then benefit from those tools!

Re: Unlocking Python's Cores:Energy Implications of Removing the GIL

#106

Earlier quoted context omitted.

A lot of that has already been solved for by scaling workers to cores along with techniques like greenlets/eventlets that support concurrency without true multithreading to take better advantage of CPU capacity.

That's great for concurrency, but doesn't improve parallelism. Unless you mean you have multiple worker processes (or GIL-free threads).

Yes, multiple worker processes is what I meant. Few web apps have a meaningful use for parallelism within a single process. So long as you’re keeping all cores busy with independent processes at high concurrency, multithreading adds relatively little.

YMMV if you’re doing a lot of number crunching.

Re: Unlocking Python's Cores:Energy Implications of Removing the GIL

#107
post #49
post #41

Can’t it just profile them and pick the right one accordingly?

Is the GIL implemented as a run-time option? I thought this feature had to be enabled at compile-time.

Python is interpreted not compiled so don’t see why not

Re: Unlocking Python's Cores:Energy Implications of Removing the GIL

#108

Earlier quoted context omitted.

Some widgets and modules, like Qt Charts (or Graphs, I forget), are dual GPL and commercially licensed, so it's a bit more complicated than that. You also need a commercial license for automotive and embedded deployments.

Right but it's a perfectly functional (even remarkably feature complete) UI toolkit without the copyleft addons. > You also need a commercial license for automotive and embedded deployments. How does that work? The LGPL (really any OSI license) isn't compatible with additional usage restrictions.

I'm guessing some parts of code are needed to make it run on those platforms and aren't LGPL.

Re: Unlocking Python's Cores:Energy Implications of Removing the GIL

#109

Earlier quoted context omitted.

Some widgets and modules, like Qt Charts (or Graphs, I forget), are dual GPL and commercially licensed, so it's a bit more complicated than that. You also need a commercial license for automotive and embedded deployments.

Right but it's a perfectly functional (even remarkably feature complete) UI toolkit without the copyleft addons. > You also need a commercial license for automotive and embedded deployments. How does that work? The LGPL (really any OSI license) isn't compatible with additional usage restrictions.

You generally can't adhere to the LGPL in automotive or embedded deployments: the user can't link their own Qt libs in their auto/embedded device.

Slint has a similar license

Re: Unlocking Python's Cores:Energy Implications of Removing the GIL

#110
post #107
post #49

Earlier quoted context omitted.

Is the GIL implemented as a run-time option? I thought this feature had to be enabled at compile-time.

Python is interpreted not compiled so don’t see why not

No, they mean that CPython must be compiled with --disable-gil
Post reply on HN