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

(PUP-11897) Handle EOF in order to avoid busy-loop #9074

Closed
wants to merge 1 commit into from

Conversation

bugfood
Copy link
Contributor

@bugfood bugfood commented Jun 22, 2023

When EOF is reached, calls to IO.select() will return immediately, resulting in puppet executing the loop without any internal blocking. This causes up to 100% usage of a CPU core until the child finishes.

If the child does its own stdout/stderr redirection before a long operation, for example, this can result in much wasted CPU usage.

There is no need to execute the body of the loop after EOF is reached, so switch the Process.waitpid2 flags to block.

When EOF is reached, calls to IO.select() will return immediately,
resulting in puppet executing the loop without any internal blocking.
This causes up to 100% usage of a CPU core until the child finishes.

If the child does its own stdout/stderr redirection before a long
operation, for example, this can result in much wasted CPU usage.

There is no need to execute the body of the loop after EOF is reached,
so switch the Process.waitpid2 flags to block.
@bugfood bugfood requested a review from a team as a code owner June 22, 2023 22:08
@puppetlabs-jenkins
Copy link
Collaborator

Can one of the admins verify this patch?

@joshcooper
Copy link
Contributor

Thank you for your contribution @bugfood! We've included your commit in this PR #9106 so I'm going to close this.

@joshcooper joshcooper closed this Sep 12, 2023
@bugfood
Copy link
Contributor Author

bugfood commented Sep 12, 2023

Thank you.

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.

None yet

3 participants