GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||
GeezerVison is showing github.com — bpo-35537: subprocess uses os.posix_spawn in some cases by vstinner · Pull Request #11452 · python/cpython Conversation
|
Expose os.posix_spawnp() https://bugs.python.org/issue35674 will allow to remove this restriction. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@pablogsal, @gpshead; @izbyshev, @serhiy-storchaka: Would you mind to review this PR? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if libc == 'glibc' and version >= (2, 26): | ||
| # glibc 2.26 added a pipe to the POSIX implementation | ||
| # of posix_spawn() to properly report errors to the parent process. | ||
| return True |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Note that the patch that added a pipe to the POSIX implementation also switched to unconditional use of fork. Since the main motivation for using posix_spawn appears to be performance benefits of vfork, it seems that glibc's POSIX implementation shouldn't be used at all. I suggest to remove this branch.
Otherwise, LGTM.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Ah. I didn't require to use vfork. But ok, I modified my PR to prefer posix_spawn() implementations which can use vfork in some cases for best performances. Let's start with a minimum platform support, and extend it later.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I don't get it. posix_spawn() uses vfork and is 61x faster than fork+exec
(_posixsubprocess) on my laptop:
https://bugs.python.org/issue35537#msg332204
Performance is one of the 2 reasons to use it. The other one is atomicity
(that I call "safety") on macOS where it's a syscall.
…--
Night gathers, and now my watch begins. It shall not end until my death.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I meant the POSIX implementation (in |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@giampaolo: Would you mind to review this change? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I can't comment on the usage of posix_spawn per-se (I wasn't aware it existed). The only comment I can provide is that I took a look at the discussion in bpo-35537 and the rationale seems to make sense (quite consistent speedup, nice one!). IMHO assuming using posix_spawn is safe, the patch as-is LGTM and considering the gain it makes sense to take the risk.
Nitpick: perhaps it would be good to include the benchmark results in whatsnew.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Honestly, I'm not 100% sure that the change is safe. But I want to make it because of the nice speedup. I prefer to push the change early during Python 3.8 devcycle, so if someone spot an issue, we have time to try to fix it, or just revert the change.
@serhiy-storchaka asked to not write it, at least not announce a generic "60x speedup": Moreover, the speedup is only enabled under very specific conditions (see the long list of conditions in my What's New in Python 3.8 entry). We can run more benchmarks later to have a better idea of the "average speedup", and so document the speedup. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Follow-up (support pipes): PR #11575. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.