Repository navigation
perf(app): spread pinned workers across physical cores before SMT siblings - #376
Merged
Merged
Conversation
…lings cwist_app_pin_worker took the (index % n)-th allowed CPU in ascending order. On hosts that number SMT siblings next to each other (0,1 / 2,3, common on many VMs and older Intel/ARM boxes), four workers landed on the two threads of two cores while other cores sat idle. Rank each allowed CPU by the number of allowed siblings with a lower ID (core_cpus_list, falling back to thread_siblings_list) and pick by (rank, ID), so every physical core gets one worker before any gets two. Without SMT, without sysfs, or with an unreadable topology file the order is the old plain ascending one; split numbering (0,N) is also unchanged. The test points the reader at a fake sysfs root and checks adjacent, split and 4-way SMT orders, a partial mask, and malformed files.
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.
Problem
cwist_app_pin_worker()pins worker i to the (i mod n)-th allowed CPU in ascending order. That only spreads workers across physical cores when the kernel numbers SMT siblings far apart (0,N). Many hosts number them next to each other (0,1,2,3, …), including many cloud VMs and some Intel and ARM boxes. On those hosts,CWIST_WORKERS=4puts the four workers on the two hyperthreads of two cores while the remaining cores sit idle.Follow-up to the #319 investigation. The benchmark box there numbers siblings
0,6, so it never showed this.Change
src/sys/app/worker_affinity.h:topology/core_cpus_list, falling back tothread_siblings_liston older kernels.0,Nnumbering, no sysfs (some containers), or an unreadable or malformed topology file. In all of these the order stays the old ascending one, so the change is a strict improvement or a no-op.0-1,2-3,4-5,6-70,4 1,5 2,6 3,70-3,4-7There's no new API or env knob, and no public header changes.
Tests
tests/test_worker_affinity.cpoints the reader at a fake sysfs root and checks:thread_siblings_listonly);The existing mock and real-child cases are unchanged; they run with no topology exposed.
On this host (12 CPUs, siblings
0,6) the real order is unchanged:0 1 … 11.taskset -c 0,1,6,7gives0 1 6 7.Local runs of the test are clean, including ASan/UBSan, and clang-format reports nothing.