New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use posix_spawn to spawn processes for more fasterness, especially on large processes #5710
Comments
Doing something like this is actually a correctness fix, not a performance fix. I'm nots sure if posix_spawn is actually useful, though, given this (note RESOLVED/FIXED state; Ulrich Drepper at his finest): http://sources.redhat.com/bugzilla/show_bug.cgi?id=10354 But, twisted.internet.process does need to be rewritten to either use posix_spawn or python-subprocess32's _posixsubprocess.c C module (or a variant thereof adding additional functionality if necessary), so that there is no python code executed between the call to fork() and the call to exec(). |
You currently can't do just about /anything/ if you want the vfork optimization in glibc. Doesn't seem too useful.
|
Replying to jknight:
A few points:
|
Worth noting that the glibc bug is open again. It seems that Drepper is no longer involved with glibc maintenance, so we no longer have to ... enjoy his inimitable style of maintaining relationships with users. Also worth noting that glibc is not the only implementation of |
Replying to glyph:
Reading this now it strikes me as somewhat unclear. What I meant to say is, as a separate ticket, we could implement the following optimization: If That program would take, as environment variables or command-line arguments, instructions on which process-attribute manipulations to perform ( This could still be a significant advantage over the current It might be advisable to have such a program for thread-safety as well, at least in the case where the subprocess is spawned as a different user. The recommended way to implement this with |
Worth noting that Python 3.8 has a built-in |
I did a quick prototype implementation in #1675 . Updates from our conversation a decade ago, other than the fact that Python now supports the API in the stdlib:
not sure about the completeness/correctness of my hack, a buch of |
10 years later. |
Fixed in 8a275db |
(Note that since this is a performance ticket, a
spawnProcess
benchmark is a prerequisite.)posix_spawn
is not burdened with the unfortunate requirement thatfork
/exec
implies, which is that user code runs in the post-fork-pre-exec environment. Many platforms do actually have practical optimizations forposix_spawn
beyond its idiomatic counterpart. These optimizations would likely be magnified by Python's often unfortunate reference-counting/gc behaviors acrossfork()
boundaries.Not to mention the fact that
posix_spawn
actually has a signature that is quite similar to Twisted'sspawnProcess
(with struct attributes instead of parameters, but hey, it's C, what do you want).Searchable metadata
The text was updated successfully, but these errors were encountered: