Honor CPU affinity in ThreadPool::getNumCores#7903
Merged
Conversation
Member
Author
|
See python's https://docs.python.org/3/library/os.html#os.process_cpu_count more motivation for this kind of thing |
kripken
reviewed
Sep 15, 2025
Member
kripken
left a comment
There was a problem hiding this comment.
Makes sense, but as we add more complexity here I think it gets important to test this. Perhaps we could add logging of the core count in verbose mode, and check that?
22e5c5c to
79dc820
Compare
Member
Author
|
Added a test! |
kripken
approved these changes
Sep 15, 2025
Member
kripken
left a comment
There was a problem hiding this comment.
Oh cool, I was thinking we'd need some annoying stuff in a python unit test, nice that there is a way to do it in lit!
79dc820 to
15d4091
Compare
kripken
reviewed
Sep 15, 2025
| run: | | ||
| ./alpine.sh apk update | ||
| ./alpine.sh apk add build-base cmake git python3 py3-pip clang ninja | ||
| ./alpine.sh apk add build-base cmake git python3 py3-pip clang ninja util-linux |
Member
There was a problem hiding this comment.
If we need this here then we likely need it in the release too:
binaryen/.github/workflows/create_release.yml
Line 138 in 15d4091
This reports that number of CPUs that are actually usable by the current process. This means that I can do something like `taskset -c 0 emcc hello.c -O2` and the internal call to `wasm-opt` within emcc will only use a single core. Ideally this would work on macOS and windows too, but I'm not even sure how easy it is to control affinity on those OSes.
15d4091 to
4474299
Compare
kripken
approved these changes
Sep 16, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This reports that number of CPUs that are actually usable by the current process.
This means that I can do something like
taskset -c 0 emcc hello.c -O2and the internal call towasm-optwithin emcc will only use a single core.Ideally this would work on macOS and windows too, but I'm not even sure how easy it is to control affinity on those OSes.