Skip to content

Commit

Permalink
Record memory.events.local
Browse files Browse the repository at this point in the history
Summary: As title

Reviewed By: antonis-m

Differential Revision: D57226252

fbshipit-source-id: 09d071360a886f56a75b27447d3b110aa27e56ab
  • Loading branch information
lnyng authored and facebook-github-bot committed May 13, 2024
1 parent 10d0da6 commit 41d7be9
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 1 deletion.
12 changes: 12 additions & 0 deletions below/cgroupfs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,10 @@ impl CgroupReader {
MemoryEvents::read(self)
}

pub fn read_memory_events_local(&self) -> Result<MemoryEventsLocal> {
MemoryEventsLocal::read(self)
}

pub fn read_cgroup_stat(&self) -> Result<CgroupStat> {
CgroupStat::read(self)
}
Expand Down Expand Up @@ -713,6 +717,14 @@ key_values_format!(MemoryEvents; memory.events; [
oom_kill
]);

key_values_format!(MemoryEventsLocal; memory.events.local; [
low,
high,
max,
oom,
oom_kill
]);

key_values_format!(CgroupStat; cgroup.stat; [nr_descendants, nr_dying_descendants]);

// Trait to add a read() method for `<string> key=value` formatted files
Expand Down
9 changes: 9 additions & 0 deletions below/cgroupfs/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,15 @@ pub struct MemoryEvents {
pub oom_kill: Option<u64>,
}

#[derive(Default, Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
pub struct MemoryEventsLocal {
pub low: Option<u64>,
pub high: Option<u64>,
pub max: Option<u64>,
pub oom: Option<u64>,
pub oom_kill: Option<u64>,
}

#[derive(Default, Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
pub struct CgroupStat {
pub nr_descendants: Option<u32>,
Expand Down
5 changes: 5 additions & 0 deletions below/dump/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,11 @@ fn test_dump_cgroup_titles() {
"Events Max",
"Events OOM",
"Events Kill",
"Events Local Low",
"Events Local High",
"Events Local Max",
"Events Local OOM",
"Events Local Kill",
"RBytes",
"WBytes",
"R I/O",
Expand Down
17 changes: 17 additions & 0 deletions below/model/src/cgroup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,11 @@ pub struct CgroupMemoryModel {
pub events_max: Option<u64>,
pub events_oom: Option<u64>,
pub events_oom_kill: Option<u64>,
pub events_local_low: Option<u64>,
pub events_local_high: Option<u64>,
pub events_local_max: Option<u64>,
pub events_local_oom: Option<u64>,
pub events_local_oom_kill: Option<u64>,
}

impl std::ops::Add for CgroupMemoryModel {
Expand Down Expand Up @@ -533,6 +538,11 @@ impl std::ops::Add for CgroupMemoryModel {
events_max: opt_add(self.events_max, other.events_max),
events_oom: opt_add(self.events_oom, other.events_oom),
events_oom_kill: opt_add(self.events_oom_kill, other.events_oom_kill),
events_local_low: opt_add(self.events_local_low, other.events_local_low),
events_local_high: opt_add(self.events_local_high, other.events_local_high),
events_local_max: opt_add(self.events_local_max, other.events_local_max),
events_local_oom: opt_add(self.events_local_oom, other.events_local_oom),
events_local_oom_kill: opt_add(self.events_local_oom_kill, other.events_local_oom_kill),
}
}
}
Expand All @@ -555,6 +565,13 @@ impl CgroupMemoryModel {
model.events_oom = events.oom;
model.events_oom_kill = events.oom_kill;
}
if let Some(events_local) = &sample.memory_events_local {
model.events_local_low = events_local.low;
model.events_local_high = events_local.high;
model.events_local_max = events_local.max;
model.events_local_oom = events_local.oom;
model.events_local_oom_kill = events_local.oom_kill;
}
if let Some(stat) = &sample.memory_stat {
model.anon = stat.anon;
model.file = stat.file;
Expand Down
1 change: 1 addition & 0 deletions below/model/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ fn collect_cgroup_sample(
memory_swap_max: wrap(reader.read_memory_swap_max())?,
memory_zswap_max: wrap(reader.read_memory_zswap_max())?,
memory_events: wrap(reader.read_memory_events())?.map(Into::into),
memory_events_local: wrap(reader.read_memory_events_local())?.map(Into::into),
inode_number: match reader.read_inode_number() {
Ok(st_ino) => Some(st_ino as i64),
Err(e) => {
Expand Down
7 changes: 6 additions & 1 deletion below/model/src/common_field_ids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
///
/// This list also servers as documentation for available field ids that could
/// be used in other below crates. A test ensures that this list is up-to-date.
pub const COMMON_MODEL_FIELD_IDS: [&str; 449] = [
pub const COMMON_MODEL_FIELD_IDS: [&str; 454] = [
"system.hostname",
"system.kernel_version",
"system.os_release",
Expand Down Expand Up @@ -209,6 +209,11 @@ pub const COMMON_MODEL_FIELD_IDS: [&str; 449] = [
"cgroup.[path:/<cgroup_path>/.]mem.events_max",
"cgroup.[path:/<cgroup_path>/.]mem.events_oom",
"cgroup.[path:/<cgroup_path>/.]mem.events_oom_kill",
"cgroup.[path:/<cgroup_path>/.]mem.events_local_low",
"cgroup.[path:/<cgroup_path>/.]mem.events_local_high",
"cgroup.[path:/<cgroup_path>/.]mem.events_local_max",
"cgroup.[path:/<cgroup_path>/.]mem.events_local_oom",
"cgroup.[path:/<cgroup_path>/.]mem.events_local_oom_kill",
"cgroup.[path:/<cgroup_path>/.]io_details.<key>.rbytes_per_sec",
"cgroup.[path:/<cgroup_path>/.]io_details.<key>.wbytes_per_sec",
"cgroup.[path:/<cgroup_path>/.]io_details.<key>.rios_per_sec",
Expand Down
1 change: 1 addition & 0 deletions below/model/src/sample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub struct CgroupSample {
pub memory_swap_max: Option<i64>,
pub memory_zswap_max: Option<i64>,
pub memory_events: Option<cgroupfs::MemoryEvents>,
pub memory_events_local: Option<cgroupfs::MemoryEventsLocal>,
pub inode_number: Option<i64>,
pub cgroup_stat: Option<cgroupfs::CgroupStat>,
pub memory_numa_stat: Option<BTreeMap<u32, cgroupfs::MemoryNumaStat>>,
Expand Down
10 changes: 10 additions & 0 deletions below/render/src/default_configs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ impl HasRenderConfigForDump for model::SingleCgroupModel {
EventsMax => None,
EventsOom => Some(counter),
EventsOomKill => Some(counter),
EventsLocalLow => None,
EventsLocalHigh => None,
EventsLocalMax => None,
EventsLocalOom => Some(counter),
EventsLocalOomKill => Some(counter),
Anon => Some(gauge.unit("bytes")),
File => Some(gauge.unit("bytes")),
Kernel => Some(gauge.unit("bytes")),
Expand Down Expand Up @@ -344,6 +349,11 @@ impl HasRenderConfig for model::CgroupMemoryModel {
EventsMax => rc.title("Events Max"),
EventsOom => rc.title("Events OOM"),
EventsOomKill => rc.title("Events Kill"),
EventsLocalLow => rc.title("Events Local Low"),
EventsLocalHigh => rc.title("Events Local High"),
EventsLocalMax => rc.title("Events Local Max"),
EventsLocalOom => rc.title("Events Local OOM"),
EventsLocalOomKill => rc.title("Events Local Kill"),
Anon => rc.title("Anon").format(ReadableSize),
File => rc.title("File").format(ReadableSize),
Kernel => rc.title("Kernel").format(ReadableSize),
Expand Down

0 comments on commit 41d7be9

Please sign in to comment.