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

Vcpkg spawns processes with IDLE_PRIORITY_CLASS, causing slow builds with low CPU usage on Windows #42715

Open
Binary-Song opened this issue Dec 15, 2024 · 6 comments · May be fixed by microsoft/vcpkg-tool#1555
Assignees
Labels
category:vcpkg-feature The issue is a new capability of the tool that doesn’t already exist and we haven’t committed

Comments

@Binary-Song
Copy link

Binary-Song commented Dec 15, 2024

Describe the bug
Build related processes like Ninja spawned by vcpkg seem to have a very low priority, causing the build to use very few CPU cores despite setting the VCPKG_MAX_CONCURRENCY to a high value.

Environment

  • OS: Windows
  • Compiler: revision

To Reproduce
Steps to reproduce the behavior:

  1. ./vcpkg install xxx
  2. Bring up Task Manager
  3. Right click on Ninja.exe, go to details
  4. Right click and look at the priority
  5. It is Low

Expected behavior
At least give it a normal priority!

Additional context
The issue is caused by this in windows_create_process which vcpkg uses to spawn subprocesses on Windows. For some reason, the priority is set to IDLE_PRIORITY_CLASS, which according to the doc, 'run only when the system is idle'. This is probably affecting the performance of vcpkg for years as it was introduced in the very beginning of the commit history.
By setting the value to NORMAL_PRIORITY_CLASS, I was able to fix this issue. Please change this or make this configurable. I would be happy to make a pr if this is indeed a bug.

@jimwang118 jimwang118 added the category:vcpkg-feature The issue is a new capability of the tool that doesn’t already exist and we haven’t committed label Dec 16, 2024
@jimwang118
Copy link
Contributor

Can you give a specific example?

@Binary-Song
Copy link
Author

Binary-Song commented Dec 16, 2024

Yes, vcpkg install llvm in the first step.

@Neumann-A
Copy link
Contributor

causing the build to use very few CPU cores

Hmm are you on a system with more than 64 cores?

@Binary-Song
Copy link
Author

Binary-Song commented Dec 16, 2024

No. The number of processes is correct (I have 24 cores and there are roughly 24 cl.exe processes in task manager). It's just the number of utilized CPUs that is clearly incorrect; these 24 processes seem to only make 8 cores go 100% on task manager, and other cores are barely working. And once I manually set the ninja.exe's priority to Normal in Task Manager. All cores were working. I tested this on my work PC today which has 32 logical cores. The problem manfested as it did on my home PC.

@dg0yt
Copy link
Contributor

dg0yt commented Dec 16, 2024

@Binary-Song
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:vcpkg-feature The issue is a new capability of the tool that doesn’t already exist and we haven’t committed
Projects
None yet
4 participants