Move C-state name cleaning to agent for smaller JSON
All checks were successful
Build and Release / build-and-release (push) Successful in 1m32s
All checks were successful
Build and Release / build-and-release (push) Successful in 1m32s
- Agent now extracts "C" + digits pattern (C3, C10) using char parsing - Removes suffixes like "_ACPI", "_MWAIT" at source - Reduces JSON payload size over ZMQ - No regex dependency - uses fast char iteration (~1μs overhead) - Robust fallback to original name if pattern not found - Dashboard simplified to use clean names directly Bump version to v0.1.212 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -135,10 +135,23 @@ impl CpuCollector {
|
||||
if let Ok(time_str) = utils::read_proc_file(&time_path) {
|
||||
if let Ok(time) = utils::parse_u64(time_str.trim()) {
|
||||
if let Ok(name) = utils::read_proc_file(&name_path) {
|
||||
let state_name = name.trim().to_string();
|
||||
let state_name = name.trim();
|
||||
// Skip POLL state (not real idle)
|
||||
if state_name != "POLL" && time > 0 {
|
||||
cstate_times.push((state_name, time));
|
||||
// Extract "C" + digits pattern (C3, C10, etc.) to reduce JSON size
|
||||
// Handles formats like "C3_ACPI", "C10_MWAIT", etc.
|
||||
let clean_name = if let Some(c_pos) = state_name.find('C') {
|
||||
let rest = &state_name[c_pos + 1..];
|
||||
let digit_count = rest.chars().take_while(|c| c.is_ascii_digit()).count();
|
||||
if digit_count > 0 {
|
||||
state_name[c_pos..c_pos + 1 + digit_count].to_string()
|
||||
} else {
|
||||
state_name.to_string()
|
||||
}
|
||||
} else {
|
||||
state_name.to_string()
|
||||
};
|
||||
cstate_times.push((clean_name, time));
|
||||
total_time += time;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user