mirror of
https://github.com/ilya-zlobintsev/LACT.git
synced 2025-02-25 18:55:26 -06:00
feat: display info about throttling (#274)
* feat: add throttling info * fix: empty throttling text
This commit is contained in:
parent
54370e9b22
commit
487b35ec18
@ -19,6 +19,7 @@ use lact_schema::{
|
||||
PciInfo, PmfwInfo, PowerState, PowerStates, PowerStats, VoltageStats, VramStats,
|
||||
};
|
||||
use pciid_parser::Database;
|
||||
use std::collections::BTreeMap;
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
cell::RefCell,
|
||||
@ -309,9 +310,38 @@ impl GpuController {
|
||||
.get_pcie_clock_levels()
|
||||
.ok()
|
||||
.and_then(|levels| levels.active),
|
||||
throttle_info: self.get_throttle_info(),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "libdrm_amdgpu_sys"))]
|
||||
fn get_throttle_info(&self) -> Option<BTreeMap<String, Vec<String>>> {
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(feature = "libdrm_amdgpu_sys")]
|
||||
fn get_throttle_info(&self) -> Option<BTreeMap<String, Vec<String>>> {
|
||||
use libdrm_amdgpu_sys::AMDGPU::ThrottlerType;
|
||||
|
||||
self.drm_handle
|
||||
.as_ref()
|
||||
.and_then(|drm_handle| drm_handle.get_gpu_metrics().ok())
|
||||
.and_then(|metrics| metrics.get_throttle_status_info())
|
||||
.map(|throttle| {
|
||||
let mut result: BTreeMap<String, Vec<String>> = BTreeMap::new();
|
||||
|
||||
for bit in throttle.get_all_throttler() {
|
||||
let throttle_type = ThrottlerType::from(bit);
|
||||
result
|
||||
.entry(throttle_type.to_string())
|
||||
.or_default()
|
||||
.push(bit.to_string());
|
||||
}
|
||||
|
||||
result
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_clocks_info(&self) -> anyhow::Result<ClocksInfo> {
|
||||
let clocks_table = self
|
||||
.handle
|
||||
|
@ -61,6 +61,24 @@ impl GpuStatsSection {
|
||||
power_current.unwrap_or(0.0),
|
||||
power_cap_current.unwrap_or(0.0)
|
||||
));
|
||||
|
||||
match &stats.throttle_info {
|
||||
Some(throttle_info) => {
|
||||
if throttle_info.is_empty() {
|
||||
self.set_throttling("No")
|
||||
} else {
|
||||
let type_text: Vec<String> = throttle_info
|
||||
.iter()
|
||||
.map(|(throttle_type, details)| {
|
||||
format!("{throttle_type} ({})", details.join(", "))
|
||||
})
|
||||
.collect();
|
||||
let text = type_text.join(", ");
|
||||
self.set_throttling(text);
|
||||
}
|
||||
}
|
||||
None => self.set_throttling("Unknown"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,6 +123,8 @@ mod imp {
|
||||
vram_usage: RefCell<f64>,
|
||||
#[property(get, set)]
|
||||
vram_usage_text: RefCell<String>,
|
||||
#[property(get, set)]
|
||||
throttling: RefCell<String>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
|
@ -75,6 +75,11 @@ template $GpuStatsSection: $PageSection {
|
||||
name: "Power Usage:";
|
||||
value: bind template.power-usage;
|
||||
}
|
||||
|
||||
$InfoRow {
|
||||
name: "Throttling:";
|
||||
value: bind template.throttling;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -179,6 +179,7 @@ pub struct DeviceStats {
|
||||
pub core_power_state: Option<usize>,
|
||||
pub memory_power_state: Option<usize>,
|
||||
pub pcie_power_state: Option<usize>,
|
||||
pub throttle_info: Option<BTreeMap<String, Vec<String>>>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
|
Loading…
Reference in New Issue
Block a user