TUI: scale CPU core-toggle granularity by core count

Cap the cores-per-row group size (and the dashboard 'g' cycle) by total core
count so the toggleable-row count stays sensible and small machines get finer
control: ≤4 cores toggle individually (size 1), 5-8 cores in groups of up to 2,
and more than 8 in groups of up to 4. The cap is also the default — the prior
fixed default of 4 now clamps to the tier (1/2/4), and an explicit
--cpu-group-size is clamped to the cap too.

Add max_group_size() in cpu_groups; update the help text and the cpu_groups /
control tests (the cycle test now uses 16 cores so it can exercise sizes 4/2/1).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
jackpotincorporated
2026-06-06 18:34:10 -04:00
parent afd56bee1b
commit 0002e90451
3 changed files with 79 additions and 33 deletions
+3 -3
View File
@@ -175,15 +175,15 @@ mod tests {
#[test]
fn protocol_get_and_set() {
let controls = Controls::new(1, 0, 0, 0, 0, true);
let cpu = CpuMining::new((0..8).collect(), 4, false); // sizes [1,2,4,8]
let cpu = CpuMining::new((0..16).collect(), 4, false); // 16 cores -> tier cap 4, sizes [1,2,4]
let stats = Stats::for_test(vec!["GPU 0".into()]);
// get: one device, cpu rows reflect the grouping (8 cores / 4 = 2 rows).
// get: one device, cpu rows reflect the grouping (16 cores / 4 = 4 rows).
let v = process("{\"op\":\"get\"}", &controls, &cpu, &stats);
assert_eq!(v["ok"], true);
assert_eq!(v["devices"].as_array().unwrap().len(), 1);
assert_eq!(v["cpu"]["group_size"], 4);
assert_eq!(v["cpu"]["rows"].as_array().unwrap().len(), 2);
assert_eq!(v["cpu"]["rows"].as_array().unwrap().len(), 4);
// set device 0 disabled.
assert!(controls.device(0).enabled());