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

os: use pidfd_open with epoll on Linux instead of blocking wait in blockUntilWaitable #60320

Open
mitar opened this issue May 20, 2023 · 3 comments · May be fixed by #60461
Open

os: use pidfd_open with epoll on Linux instead of blocking wait in blockUntilWaitable #60320

mitar opened this issue May 20, 2023 · 3 comments · May be fixed by #60461
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@mitar
Copy link
Contributor

mitar commented May 20, 2023

My understanding is that in blockUntilWaitable the waitid call blocks the thread you call it on. On Linux, we could instead use pidfd_open and then monitor the file descriptor with epool:

When the process that it refers to terminates, these interfaces (e.g., epool) indicate the file descriptor as readable.

I think this would then not block the thread?

@mitar mitar added the Proposal label May 20, 2023
@gopherbot gopherbot added this to the Proposal milestone May 20, 2023
@ianlancetaylor
Copy link
Contributor

I don't see any API change here, so this doesn't have to be a proposal. Taking it out of the proposal process.

@ianlancetaylor ianlancetaylor changed the title proposal: os/exec: Use pidfd_open with epool on Linux instead of blocking wait in blockUntilWaitable os: use pidfd_open with epool on Linux instead of blocking wait in blockUntilWaitable May 20, 2023
@ianlancetaylor ianlancetaylor added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed Proposal labels May 20, 2023
@ianlancetaylor ianlancetaylor modified the milestones: Proposal, Backlog May 20, 2023
@prattmic prattmic changed the title os: use pidfd_open with epool on Linux instead of blocking wait in blockUntilWaitable os: use pidfd_open with epoll on Linux instead of blocking wait in blockUntilWaitable May 22, 2023
mitar added a commit to mitar/go that referenced this issue May 26, 2023
Using pidfd allows us to have a handle on the process and
poll the handle to non-blocking wait for the process to
exit.

Fixes golang#34396
Fixes golang#60321
Fixes golang#60320
@mitar
Copy link
Contributor Author

mitar commented May 26, 2023

OK, I made a draft of the implementation in #60461 to test how would this work out. It is not yet perfect (see comments on Gerrit), but it gives me/us something to play around. I think it works pretty nice.

mitar added a commit to mitar/go that referenced this issue May 26, 2023
Using pidfd allows us to have a handle on the process and
poll the handle to non-blocking wait for the process to
exit.

Fixes golang#34396
Fixes golang#60321
Fixes golang#60320
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/498615 mentions this issue: os/exec: use pidfd for waiting and signaling of processes

mitar added a commit to mitar/go that referenced this issue May 26, 2023
Using pidfd allows us to have a handle on the process and
poll the handle to non-blocking wait for the process to
exit.

Fixes golang#34396
Fixes golang#60321
Fixes golang#60320
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants