News for hackers. Stuff that matters.
Re:Python stands to lose its GIL, and gain a lot of speed by lazide on Sunday October 17, 2021 @12:20PM (#28897540)
Even with copy-on-write? Have any actual numbers?
Re:Python stands to lose its GIL, and gain a lot of speed by kaba0 on Sunday October 17, 2021 @02:45PM (#28898720)
What about context switches as well, much slower IPC, and basically “no native support”.
Re:Python stands to lose its GIL, and gain a lot of speed by lazide on Sunday October 17, 2021 @09:17PM (#28901328)
Depends on the workload if it matters or not. Some it matters a ton, some not a bit. And if you have n=cores processes, you can get some benefits with collocation and the like the OS can do for you.
Re:Python stands to lose its GIL, and gain a lot of speed by kaba0 on Monday October 18, 2021 @10:45AM (#28905954)
But I also meant to highlight that you can’t simply lock on an object, can’t yield/notify other threads, etc.

While performance may not matter, productivity very much suffers from multi-process programming.

Re:Python stands to lose its GIL, and gain a lot of speed by lazide on Monday October 18, 2021 @02:53PM (#28909805)
I’m not saying performance is not different between these types of solutions or the dev work is not sometimes different.

I’m saying that the penalties (including development effort) for work co-ordinated between processes compared to threads can vary from nearly zero (sometimes even net better) to terrible depending on the nature of the workload. Threads are very convenient programmatically, but also have some serious drawbacks in certain scenarios.

For instance fork()’d sub-processes do a good job of avoiding segfaulting /crashing/dead locking everything all at once if there is a memory issue or other problem when doing the work, it’s very difficult in native threading models to do per-work resource management or quotas (like maximum memory footprint, or max number of open sockets, or max number of open files) since everything is grouped together at the OS level and it’s a lot of work to reinvent that yourself (which you’d need to do with threads). Also, the same shared memory convenience can cause some pretty crazy memory corruption in otherwise isolated areas of your system if you’re not careful, which is not possible with separate processes.

I do wish the python concurrency model was better. Even with it’s warts, it is still possible to do a LOT with it in a performant way. Some workloads are definitely not worth the trouble now however.

Re:Python stands to lose its GIL, and gain a lot of speed by SkittyDog on Sunday October 17, 2021 @12:27PM (#28897593)
Actual work is left as an exercise for the reader ;-)
Re:Python stands to lose its GIL, and gain a lot of speed by lazide on Sunday October 17, 2021 @12:46PM (#28897746)
Last I did this, when the processes were fork()‘s of the parent (the typical way this was done), memory overhead was minimal compared to threads. A couple %. That was somewhat workload dependent however, if there is a lot of memory churn or data marshaling/unmarshalling happening as part of the workload, they’ll quickly diverge and you’ll burn a ton of CPU doing so.

Typical ways around that include mmap’ng things or various types of shared memory IPC, but that is a lot of work.