diff options
author | Brian Chen <brianc118@meta.com> | 2024-01-04 07:41:05 -0800 |
---|---|---|
committer | Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com> | 2024-01-04 07:41:05 -0800 |
commit | c573cbf0689a1ca62bb80aa0046b3cc95b8c5b9e (patch) | |
tree | 4f4178ec13e7e853a76fc8192b77060a660c083e | |
parent | 00d15c66fa603e8023eb9523917c2c7dec7eddf8 (diff) |
Add counter for number of accelerators (#8217)
Summary: Pull Request resolved: https://github.com/facebookincubator/below/pull/8217
Reviewed By: lnyng
Differential Revision: D52448660
fbshipit-source-id: 6753510180356ce8a1574f5db4f128c7cd1cb495
-rw-r--r-- | below/src/main.rs | 8 | ||||
-rw-r--r-- | below/src/open_source/statistics.rs | 6 |
2 files changed, 11 insertions, 3 deletions
diff --git a/below/src/main.rs b/below/src/main.rs index e281424e..5bc61156 100644 --- a/below/src/main.rs +++ b/below/src/main.rs @@ -973,7 +973,7 @@ fn record( compress_opts.to_compression_mode()?, store::Format::Cbor, )?; - let mut stats = statistics::Statistics::new(); + let mut stats = statistics::Statistics::new(init.clone()); let (exit_buffer, bpf_errs) = if disable_exitstats { (Arc::new(Mutex::new(procfs::PidMap::new())), None) @@ -1058,13 +1058,17 @@ fn record( match collected_sample { Ok(s) => { - match store.put(post_collect_sys_time, &DataFrame { sample: s }) { + let frame = DataFrame { sample: s }; + match store.put(post_collect_sys_time, &frame) { Ok(/* new shard */ true) => { cleanup_store(&store, &logger, store_size_limit, /* retention */ None)? } Ok(/* new shard */ false) => {} Err(e) => error!(logger, "{:#}", e), } + if below_config.enable_gpu_stats { + stats.report_nr_accelerators(&frame.sample); + } } Err(e) => { // Handle cgroupfs errors diff --git a/below/src/open_source/statistics.rs b/below/src/open_source/statistics.rs index ba731903..8e67b030 100644 --- a/below/src/open_source/statistics.rs +++ b/below/src/open_source/statistics.rs @@ -14,14 +14,18 @@ use std::path::Path; +use crate::init; + pub struct Statistics {} impl Statistics { - pub fn new() -> Statistics { + pub fn new(_init_token: init::InitToken) -> Statistics { Statistics {} } pub fn report_store_size<P: AsRef<Path>>(&mut self, _dir: P) {} pub fn report_collection_skew(&mut self) {} + + pub fn report_nr_accelerators(&mut self, _sample: &model::Sample) {} } |