Skip to content
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

5710 initial implementation of using posix_spawn #1675

Merged
merged 21 commits into from
Mar 14, 2023
Merged

Conversation

glyph
Copy link
Member

@glyph glyph commented Dec 16, 2021

Scope and purpose

Add a few words about why this PR is needed and what is its scope.

Add any comments about trade-offs (if any) made in this PR and the reasoning behind them.

Add mentions of things that are not covered here and are planed to be done in separate PRs.

Contributor Checklist:

  • The associated ticket in Trac is here: https://twistedmatrix.com/trac/ticket/5710
  • I ran tox -e lint to format my patch to meet the Twisted Coding Standard
  • I have created a newsfragment in src/twisted/newsfragments/ (see: News files)
  • The title of the PR starts with the associated Trac ticket number (without the # character).
  • I have updated the automated tests and checked that all checks for the PR are green.
  • I have submitted the associated Trac ticket for review by adding the word review to the keywords field in Trac, and putting a link to this PR in the comment; it shows up in https://twisted.reviews/ now.
  • The merge commit will use the below format
    The first line is automatically generated by GitHub based on PR ID and branch name.
    The other lines generated by GitHub should be replaced.
Author: glyph
Reviewer: 
Fixes: ticket:5710

Twisted will now use the more efficient `posix_spawn` process-spawning mechanism when the parameters passed allow for it, replacing `fork`/`exec`.

@glyph glyph changed the title initial implementation of using posix_spawn 5710 initial implementation of using posix_spawn Jan 17, 2022
@glyph glyph marked this pull request as ready for review January 17, 2022 07:10
@glyph
Copy link
Member Author

glyph commented Jan 17, 2022

One follow-up I can think of here is making the usage of posix_spawn a bit more visible. It might be a huge performance boost for some applications, and those should be able to figure out what it was that made a difference.

Copy link
Member

@wsanchez wsanchez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems legit to me

@@ -643,6 +677,7 @@ def __init__(
nuances of setXXuid on UNIX: it will assume that either your effective
or real UID is 0.)
"""
self._reactor = reactor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than hanging a new attribute on the object, perhaps just pass this along to _fork and then _trySpawnInsteadOfFork?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that having _reactor class/instance member is ok.
It's a common patter and makes testing much easier.

The _trySpawnInsteadOfFork is private API, so I think that doing a dependency injection there is more complicated.

Copy link
Member

@adiroiban adiroiban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good. Thanks. Ready to merge.

@@ -643,6 +677,7 @@ def __init__(
nuances of setXXuid on UNIX: it will assume that either your effective
or real UID is 0.)
"""
self._reactor = reactor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that having _reactor class/instance member is ok.
It's a common patter and makes testing much easier.

The _trySpawnInsteadOfFork is private API, so I think that doing a dependency injection there is more complicated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants