fix(runtime): cpu topology corrections

This commit is contained in:
Alex Zenla
2024-06-29 00:47:08 -07:00
parent 15e57f9055
commit 399df91170
5 changed files with 31 additions and 26 deletions

View File

@ -42,6 +42,7 @@ fn labelled_topo(input: &[SysctlCputopo]) -> Vec<CpuTopologyInfo> {
class: CpuClass::Standard,
}],
);
last = Some(*item);
continue;
}
@ -73,6 +74,13 @@ fn labelled_topo(input: &[SysctlCputopo]) -> Vec<CpuTopologyInfo> {
pe_cores = true;
} else if pe_cores && last.map(|last| item.core == last.core + 1).unwrap_or(false) {
// detect efficiency cores if P/E cores are in use.
if let Some(last) = last {
if let Some(list) = cores.get_mut(&(last.core, last.socket, last.node)) {
for other in list {
other.class = CpuClass::Efficiency;
}
}
}
let list = cores
.entry((item.core, item.socket, item.node))
.or_default();
@ -108,7 +116,7 @@ fn labelled_topo(input: &[SysctlCputopo]) -> Vec<CpuTopologyInfo> {
});
}
}
last = Some(item.clone());
last = Some(*item);
}
for threads in cores.values_mut() {
@ -117,11 +125,7 @@ fn labelled_topo(input: &[SysctlCputopo]) -> Vec<CpuTopologyInfo> {
}
}
cores
.into_values()
.into_iter()
.flatten()
.collect::<Vec<_>>()
cores.into_values().flatten().collect::<Vec<_>>()
}
impl PowerManagementContext {