Skip to content

[llvm-foreach] Avoid running llvm-foreach when waiting for child processes #17260

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

Merged
merged 3 commits into from
Mar 5, 2025

Conversation

asudarsa
Copy link
Contributor

@asudarsa asudarsa commented Mar 2, 2025

This resolves #15177

Currently, we have a 'while' loop that keeps checking for child processes to complete. This causes llvm-foreach to run and consume resources when its child processes are active.
Instead, we can use blocking waits to wait for child processes. During blocking waits. parent process is idle and does not consume resources.

I tested this on a fairly large program compilation (with AOT) and it seems to work as expected.

No new tests are needed.
Thanks

@asudarsa asudarsa requested a review from a team as a code owner March 2, 2025 18:14
@asudarsa
Copy link
Contributor Author

asudarsa commented Mar 2, 2025

@vmaksimo

Can you please take a look as you have worked on this before?

Thanks

@asudarsa asudarsa requested a review from vmaksimo March 2, 2025 18:15
Signed-off-by: Sudarsanam, Arvind <[email protected]>
Signed-off-by: Sudarsanam, Arvind <[email protected]>
@maarquitos14
Copy link
Contributor

@asudarsa did you do any performance measurement? I'm afraid this change might degrade performance, at least in scenarios where some jobs take longer than others. If I'm right --there is performance regression--, what do you think about doing this under an option? This way, user could choose whether they prefer better performance at the expense of consuming more CPU, or worse performance but with CPU idle.

@asudarsa
Copy link
Contributor Author

asudarsa commented Mar 3, 2025

@asudarsa did you do any performance measurement? I'm afraid this change might degrade performance, at least in scenarios where some jobs take longer than others. If I'm right --there is performance regression--, what do you think about doing this under an option? This way, user could choose whether they prefer better performance at the expense of consuming more CPU, or worse performance but with CPU idle.

Hi @maarquitos14

Thanks for looking into this. I did run this on one of the time consuming compilation benchmarks that we have and verified that we do not have any regression for both serial and parallel compilation scenarios.
In this PR, I have just replaced several 'while' loops that keep checking if child processes are complete with blocking waits. We still start execution of jobs in parallel. I have only modified the way in which we wait.

Thanks

Copy link
Contributor

@maarquitos14 maarquitos14 left a comment

Choose a reason for hiding this comment

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

LGTM.

@againull againull merged commit 2d610d1 into intel:sycl Mar 5, 2025
21 checks passed
@fwyzard
Copy link
Contributor

fwyzard commented Mar 5, 2025

Thanks for the fix !

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.

llvm-foreach takes 100% cpu usage
4 participants