-
Notifications
You must be signed in to change notification settings - Fork 91
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
scx_layered: Use topology for core selection #510
Conversation
scheds/rust/scx_layered/src/main.rs
Outdated
@@ -1030,16 +1048,43 @@ impl Layer { | |||
} | |||
} | |||
|
|||
let mut nodes = topo.nodes().iter().collect::<Vec<_>>().clone(); | |||
let num_nodes = nodes.len(); | |||
nodes.rotate_left(if idx <= num_nodes { idx } else { idx % num_nodes }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the main logic, it makes use of rotate_left
, which annoyingly will panic if the rotate size is too large. To get around that it mods by the number of nodes, llcs, or cores if the number of layers is larger than any of those values.
b130a8c
to
7f01ad3
Compare
let available_cores = self.cpus_to_cores(&available_cpus).ok()?; | ||
|
||
for alloc_core in layer.core_alloc_order() { | ||
match available_cores.get(*alloc_core) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this goes from the core id to the bitmask bit for checking if the core is allowed to be used
scheds/rust/scx_layered/src/main.rs
Outdated
let num_nodes = nodes.len(); | ||
let is_left = idx % 2 == 0; | ||
if is_left { | ||
nodes.rotate_left(if idx <= num_nodes { idx } else { idx % num_nodes }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe sth like let rot_by |idx, len| if idx <= len { idx } else { idx % len };
would help? Hmm... isn't this the same as idx % num_nodes
?
7f01ad3
to
3e2ff83
Compare
Currently the core selection logic in scx_layered uses the first available core in the bitmask. This is suboptimal when the scheduler is configured with specific NUMA/LLC restrictions. The ideal core selection logic should try to find the least used cores within the preferred scheduling domain and allocate new cpus from shared cores within that domain. Signed-off-by: Daniel Hodges <[email protected]>
3e2ff83
to
b3793e0
Compare
Fix a bug introduced in sched-ext#510 where it assumed core ids are incremental. This refactors the core ordering for layers to be far more simple and provide some space for layer core isolation in low utilization. Signed-off-by: Daniel Hodges <[email protected]>
Currently the core selection logic in scx_layered uses the first available core in the bitmask. This is suboptimal when the scheduler is configured with specific NUMA/LLC restrictions and with multiple layers. This refactors the core selection to use a preferred order of cores based on the layer index.