Live data from Hacker News

gh-116167: Allow disabling the GIL

github.com

111–120 of 259 posts

Re: gh-116167: Allow disabling the GIL

#111
post #39

Earlier quoted context omitted.

Python supports types! https://www.mypy-lang.org/

This seems a bit like saying "JavaScript supports types!" because of typescript.

Types are way more mainstream in the JS ecosystem than they are in the Python ecosystem. If you want a "scripty" language with types, then TypeScript is a reasonable choice.

Re: gh-116167: Allow disabling the GIL

#112
post #99
post #72

Earlier quoted context omitted.

Although true, it doesn't mean they can't improve its performance. Working with threads is a pain in Python. If you want to spawn +10-20 threads in a process, it can quickly become way slower than running a single thread. Removing the GIL and refactoring some of the core will unlock levels of concurrency that are currently not feasible with Python. And that's a great deal, in my opinion. Well worth the trouble they'r…

Working with threads is a pain regardless of which language you use. Some might say: "Use Go!" Alas: https://songlh.github.io/paper/go-study.pdf After a couple decades of coding, I can say that threading is better if it's tightly controlled, limited to usages of tight parallelism of an algorithm. Where it doesn't work is in a generic worker pool where you need to put mutex locks around everything -- and then prod ran…

Concurrency with rayon in Rust isn't pain, I'd say. It's basically hidden away from the user.

Re: gh-116167: Allow disabling the GIL

#113

Earlier quoted context omitted.

Mojo should be viewed as an attack on the Python ecosystem due to it being a superset. It can consume Python, but it itself is not Python. Taichi is really underrated, it works across all platforms (including Metal), has tons of examples and the code is easy to write. And lastly, it integrates with the ecosystem and doesn't displace it. https://github.com/taichi-dev great demo reel of what Taichi can do, https://www.…

Never heard of taichi before looks promising. Do you know any shop that uses it for prod code?

ETH Zurich is using it for their physics sim courses, University of Utah is using it for simulations (SIGGRAPH 2022), OPPO (they make smart devices running Android), Kuaishou uses it for liquid and gas simulation on GPUs. Lots of GPU accelerated sim stuff.

https://www.taichi-lang.org/

https://www.researchgate.net/publication/337118128_Taichi_a_...

https://github.com/taichi-dev/taichi

Re: gh-116167: Allow disabling the GIL

#114
post #105

Earlier quoted context omitted.

There's no need to pretend Python has virtues which it lacks. It's not a fast language. It's fast enough for many purposes, sure, but it isn't fast, and this work is unlikely to change that. Fast er , sure, and that's great.

This is entirely fair, and I wish I'd been a little less grumpy in my initial reply (I assign some blame to just getting over an illness). Thank you for the gentle correction! That said - I think it's fair to be irritated by people who write Python off as entirely useless because it is not _the fastest_ language. As you rightly say - it's fast enough for many purposes. It does bother me to see Python immediately coun…

In some ways the weakness even was a virtue. Because Python threads are slow Python has incredible toolsets for multiprocess communication, task queues, job systems, etc.

Re: gh-116167: Allow disabling the GIL

#115

First I read the news of tranched bread, and now this?! What a time! I was a bit disheartened when the Unladen Swallow project [1] fizzled out. Great to see Python back on the core optimization track. [1] https://en.wikipedia.org/wiki/CPython#Unladen_Swallow

tranched bread?

Re: gh-116167: Allow disabling the GIL

#116
post #19

Earlier quoted context omitted.

Managing processes is more annoying than threads, though. Incl. data passing and so forth.

The "ray" library makes running python code on multi core and clusters very easy.

Although its great the library helps with multicore Python, the existence of such package shouldnt be an excuse not to improve the state of things in std python

Re: gh-116167: Allow disabling the GIL

#117

Earlier quoted context omitted.

You seem to be implying that there is something inherently slow to Python. What? This topic is an example: a detail of one particular implementation, since GIL is definitely not inherent to the language. Just the usual worry about looseness of types?

CPython is slow. That's not really something you can dispute. It is a non-optimizing bytecode interpreter and it makes no use of JIT compilation. JavaScript with V8 or any other modern JIT JS engine runs circles around it. Go, Java, and C# are an order of magnitude faster but they have type systems that make optimizing compilation much easier. There's no language-inherent reason why Python can't be at least as fast a…

I've read that it can't even be as fast as JS, because everything is monkey-patchable at runtime. Maybe they can optimize for that when it doesn't happen, but remains to be seen.

Re: gh-116167: Allow disabling the GIL

#118

Earlier quoted context omitted.

What sucked about FastAPI?

Not fast enough! I used it to call llama.cpp server but it would crash if requests were "too fast". Calling the llama.cpp server directly solved the issue.

This sounds like a layer 8 problem

Re: gh-116167: Allow disabling the GIL

#119
post #99
post #72

Earlier quoted context omitted.

Although true, it doesn't mean they can't improve its performance. Working with threads is a pain in Python. If you want to spawn +10-20 threads in a process, it can quickly become way slower than running a single thread. Removing the GIL and refactoring some of the core will unlock levels of concurrency that are currently not feasible with Python. And that's a great deal, in my opinion. Well worth the trouble they'r…

Working with threads is a pain regardless of which language you use. Some might say: "Use Go!" Alas: https://songlh.github.io/paper/go-study.pdf After a couple decades of coding, I can say that threading is better if it's tightly controlled, limited to usages of tight parallelism of an algorithm. Where it doesn't work is in a generic worker pool where you need to put mutex locks around everything -- and then prod ran…

> After a couple decades of coding, I can say that threading is better if it's tightly controlled, limited to usages of tight parallelism of an algorithm.

This may be a case of violent agreement, but there are a few clear cases where multithreading is easily viable. The best case is some sort of parallel-for construct, even if you include parallel reductions, although there may need to be some smarts around how to do the reduction (e.g., different methods for reduce-within-thread versus reduce-across-thread). You can extend this to heterogeneous parallel computations, a general, structured fork-join form of concurrency. But in both cases, you essentially have to forbid inter-thread communication between the fork and the join parameters. There's another case you might be able to make work, where you have a thread act as an internal server that runs all requests to completion before attempting to take on more work.

What the paper you link to is pointing out, in short, is that message passing doesn't necessarily free you from the burden of shared-mutable-state-is-bad concurrency. The underlying problem is largely that communication between different threads (or even tasks within a thread) can only safely occur at a limited number of safe slots, and any communication outside of that is risky, be it an atomic RMW access, a mutex lock, or waiting on a message in a channel.

Re: gh-116167: Allow disabling the GIL

#120
post #109

Earlier quoted context omitted.

Python is just the more popular language. Julia array manipulation is mostly better (better syntax, better integration, larger standard library) or as good as python. Julia is also dynamically typed. It is also faster than Python, except for the jit issues.

> It is also faster than Python, except for the jit issues. I was intrigued by Julia a while ago, but didn't have time to properly learn it. So just out of curiosity: what's the issues with jit and Julia ?

Julia's JIT compiles code when its first executed, so Julia has a noticable delay from you start the program and until it starts running. This is anywhere from a few hundred milliseconds for small scripts, to tens of seconds or even minutes for large packages.
Post reply on HN