summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Chen <brianc118@meta.com>2023-07-07 08:38:50 -0700
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>2023-07-07 08:38:50 -0700
commiteba5bc32f0d61c5a145819f9271dcd62189535a4 (patch)
treeb80d57d13d5bb430a7fc42966a887032ec66ae6a
parent5cbb80b7f28a17cb0f5946b84988b33219215c24 (diff)
Deprecate Stat::cpus field
Summary: This is a breaking change. New clients will be unable to read old data. We are already using Stat::cpus_map which is identical but keyed by CPU. Reviewed By: lnyng Differential Revision: D46946087 fbshipit-source-id: 8eb197e981d1065fa4fd37a7ec634e7ef58b2370
-rw-r--r--below/model/src/system.rs19
-rw-r--r--below/procfs/src/lib.rs1
-rw-r--r--below/procfs/src/test.rs7
-rw-r--r--below/procfs/src/types.rs2
4 files changed, 3 insertions, 26 deletions
diff --git a/below/model/src/system.rs b/below/model/src/system.rs
index 0f300964..438587cd 100644
--- a/below/model/src/system.rs
+++ b/below/model/src/system.rs
@@ -55,7 +55,7 @@ impl SystemModel {
_ => Default::default(),
};
- let mut cpus: BTreeMap<u32, SingleCpuModel> = match (
+ let cpus: BTreeMap<u32, SingleCpuModel> = match (
last.and_then(|(last, _)| last.stat.cpus_map.as_ref()),
sample.stat.cpus_map.as_ref(),
) {
@@ -74,23 +74,6 @@ impl SystemModel {
_ => Default::default(),
};
- if cpus.is_empty() {
- cpus = match (
- last.and_then(|(last, _)| last.stat.cpus.as_ref()),
- sample.stat.cpus.as_ref(),
- ) {
- (Some(prev), Some(curr)) => std::iter::successors(Some(0), |idx| Some(idx + 1))
- .zip(prev.iter().zip(curr.iter()))
- .map(|(idx, (prev, curr))| (idx as u32, SingleCpuModel::new(idx, prev, curr)))
- .collect(),
- (_, Some(curr)) => std::iter::successors(Some(0), |idx| Some(idx + 1))
- .zip(curr.iter())
- .map(|(idx, _curr)| (idx, Default::default()))
- .collect(),
- _ => Default::default(),
- };
- }
-
let mem = Some(MemoryModel::new(&sample.meminfo)).unwrap_or_default();
let vm = last
.map(|(last, duration)| VmModel::new(&last.vmstat, &sample.vmstat, duration))
diff --git a/below/procfs/src/lib.rs b/below/procfs/src/lib.rs
index 667d04af..bf43a30a 100644
--- a/below/procfs/src/lib.rs
+++ b/below/procfs/src/lib.rs
@@ -256,7 +256,6 @@ impl ProcReader {
}
}
if !cpus_map.is_empty() {
- stat.cpus = Some(cpus_map.values().cloned().collect());
stat.cpus_map = Some(cpus_map);
}
diff --git a/below/procfs/src/test.rs b/below/procfs/src/test.rs
index 3d554cd4..04112ee4 100644
--- a/below/procfs/src/test.rs
+++ b/below/procfs/src/test.rs
@@ -188,11 +188,8 @@ softirq 15518280031 0 3506477306 138437 1090758178 117192437 0 24543 800441241 9
assert_eq!(total_cpu.guest_nice_usec, Some(0));
- let cpu23_from_vec = &stat.cpus.expect("Failed to read cpus")[22];
- assert_eq!(cpu23_from_vec.user_usec, Some(59379430000));
-
- let cpu23_from_map = &stat.cpus_map.expect("Failed to read cpus_map")[&23];
- assert_eq!(cpu23_from_map.user_usec, Some(59379430000));
+ let cpu23 = &stat.cpus_map.expect("Failed to read cpus_map")[&23];
+ assert_eq!(cpu23.user_usec, Some(59379430000));
assert_eq!(stat.total_interrupt_count, Some(29638874355));
assert_eq!(stat.context_switches, Some(48203489122));
diff --git a/below/procfs/src/types.rs b/below/procfs/src/types.rs
index ae97e267..967769a4 100644
--- a/below/procfs/src/types.rs
+++ b/below/procfs/src/types.rs
@@ -35,8 +35,6 @@ pub struct CpuStat {
#[derive(Default, Clone, PartialEq, Debug, Serialize, Deserialize)]
pub struct Stat {
pub total_cpu: Option<CpuStat>,
- // TODO: deprecate in favor of cpus_map
- pub cpus: Option<Vec<CpuStat>>,
pub cpus_map: Option<BTreeMap<u32, CpuStat>>,
pub total_interrupt_count: Option<u64>,
pub context_switches: Option<u64>,