Skip to content

Commit

Permalink
refactor: 优化核心温控逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
shadow3aaa committed Nov 10, 2024
1 parent 89bfb3a commit f8723bc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
8 changes: 4 additions & 4 deletions module/games.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ scene_game_list = true

[powersave]
margin = 3
temp_thresh = 60000
core_temp_thresh = 60000

[balance]
margin = 2
temp_thresh = 75000
core_temp_thresh = 75000

[performance]
margin = 1
temp_thresh = 90000
core_temp_thresh = 90000

[fast]
margin = 0
temp_thresh = 95000
core_temp_thresh = 95000
2 changes: 1 addition & 1 deletion src/framework/config/data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub struct Config {
#[derive(Debug, Serialize, Deserialize, Clone, Copy)]
pub struct ModeConfig {
pub margin: u64,
pub temp_thresh: TemperatureThreshold,
pub core_temp_thresh: TemperatureThreshold,
}

#[derive(Debug, Serialize, Deserialize, Clone, Copy)]
Expand Down
3 changes: 2 additions & 1 deletion src/framework/scheduler/looper/policy/controll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ pub fn calculate_control(
return None;
}

let target_fps = f64::from(buffer.target_fps_state.target_fps?) + target_fps_offset;
let target_fps = f64::from(buffer.target_fps_state.target_fps?);
let target_fps = (target_fps + target_fps_offset).clamp(0.0, target_fps);
let normalized_last_frame = if buffer.frametime_state.additional_frametime == Duration::ZERO {
buffer.frametime_state.frametimes.front().copied()?
} else {
Expand Down
16 changes: 7 additions & 9 deletions src/framework/scheduler/looper/thermal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::{framework::config::TemperatureThreshold, Config, Mode};

pub struct Thermal {
target_fps_offset: f64,
temperature: u64,
core_temperature: u64,
nodes: Vec<PathBuf>,
}

Expand All @@ -43,32 +43,30 @@ impl Thermal {

Ok(Self {
target_fps_offset: 0.0,
temperature: 0,
core_temperature: 0,
nodes,
})
}

pub fn target_fps_offset(&mut self, config: &mut Config, mode: Mode) -> f64 {
let target = match config.mode_config(mode).temp_thresh {
TemperatureThreshold::Disabled => {
return 0.0;
}
let target_core_temperature = match config.mode_config(mode).core_temp_thresh {
TemperatureThreshold::Disabled => u64::MAX,
TemperatureThreshold::Temp(t) => t,
};

self.temperature_update();
if self.temperature > target {
if self.core_temperature > target_core_temperature {
self.target_fps_offset -= 0.1;
} else {
self.target_fps_offset += 0.1;
}

self.target_fps_offset = self.target_fps_offset.clamp(-5.0, 0.0);
// self.target_fps_offset = self.target_fps_offset.clamp(-5.0, 0.0);
self.target_fps_offset
}

fn temperature_update(&mut self) {
self.temperature = self
self.core_temperature = self
.nodes
.iter()
.filter_map(|path| fs::read_to_string(path).ok())
Expand Down

0 comments on commit f8723bc

Please sign in to comment.