diff --git a/.gitignore b/.gitignore index e69de29..6bf432f 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +_untracked/ \ No newline at end of file diff --git a/modules/hosts/t2mbp/configuration.nix b/modules/hosts/t2mbp/configuration.nix index 40de3bf..8259282 100644 --- a/modules/hosts/t2mbp/configuration.nix +++ b/modules/hosts/t2mbp/configuration.nix @@ -49,7 +49,7 @@ # Upstream averages 50 samples (~5s); peak tracks spikes so fans hit sysfs max sooner # under bursty browser/GPU load (see patches/t2fanrd-use-peak-temperature.patch). package = inputs.t2fanrd.packages.x86_64-linux.default.overrideAttrs (old: { - patches = (old.patches or [ ]) ++ [ ../../../patches/t2fanrd-use-peak-temperature.patch ]; + patches = (old.patches or [ ]) ++ [ ../../../patches/t2fanrd-use-peak-temperature.patch ]; #TODO[epic=Moderate] Move patch file to host's directory. }); config = { Fan1 = { diff --git a/patches/t2fanrd-use-peak-temperature.patch b/patches/t2fanrd-use-peak-temperature.patch new file mode 100644 index 0000000..346f2bd --- /dev/null +++ b/patches/t2fanrd-use-peak-temperature.patch @@ -0,0 +1,27 @@ +--- a/src/main.rs ++++ b/src/main.rs +@@ -174,19 +174,20 @@ fn start_temp_loop( + } + } + +- let sum_temp: u16 = temps.iter().map(|t| *t as u16).sum(); +- let mean_temp = sum_temp / (temps.len() as u16); +- if mean_temp == last_temp { ++ // Max over the rolling window tracks spikes; the upstream mean can lag several ++ // seconds behind bursty GPU/CPU load. ++ let control_temp = temps.iter().copied().max().expect("non-empty after push_back"); ++ if control_temp == last_temp { + std::thread::sleep(std::time::Duration::from_secs(1)); + was_long_sleep = true; + } else { +- last_temp = mean_temp; ++ last_temp = control_temp; + for fan in fans { +- fan.set_speed(fan.calc_speed(mean_temp as u8))?; ++ fan.set_speed(fan.calc_speed(control_temp))?; + } + + std::thread::sleep(std::time::Duration::from_millis(100)); + was_long_sleep = false; + } + }