[Info-vax] Apache + mod_php performance
Lawrence D'Oliveiro
ldo at nz.invalid
Mon Sep 30 21:36:12 EDT 2024
On Mon, 30 Sep 2024 20:48:53 -0400, Arne Vajhøj wrote:
> The world is moving from forking processes to starting threads.
That was tried in the 1990s -- threads for everything, even multithreaded
GUIs. It was soon discovered that was not a great idea.
Java, perhaps, embraced threads more than anybody: it made such heavy use
of threads that it never even bothered to define a separate “lock” object
type: instead, locking calls are built into the behaviour of every object!
No other language copied that feature. Wonder why not?
> As soon as Python are done getting rid of GIL then it will
> join the thread party!
We understand better what to use threads for these days. They are good for
CPU-intensive tasks that are parallelizable, not so much for anything
else. That CPU-intensive stuff is not something you would tend to do in
Python itself anyway: for high performance, you would delegate those tasks
to “extension modules” written in C or such compiled languages. The usual
flow within the extension code is
* Grab data from Python objects into some efficient native format
* Free the GIL
* Perform CPU-intensive tasks
* Re-acquire the GIL
* return results in Python objects
That third step takes full advantage of multithreading, without having to
worry about the strictures of the Python GIL.
More information about the Info-vax
mailing list