Skip to content

Commit

Permalink
Track shared memory in metrics (#5023)
Browse files Browse the repository at this point in the history
* Track shared memory so we can exclude them form resident memory.

* Bump psutil version to 3.3.0 to get shared memory metrics.
  • Loading branch information
jimmygchen authored Jan 5, 2024
1 parent 01994c4 commit 0c97762
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 32 deletions.
40 changes: 9 additions & 31 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion common/eth2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pretty_reqwest_error = { workspace = true }
tokio = { workspace = true }

[target.'cfg(target_os = "linux")'.dependencies]
psutil = { version = "3.2.2", optional = true }
psutil = { version = "3.3.0", optional = true }
procfs = { version = "0.15.1", optional = true }

[features]
Expand Down
3 changes: 3 additions & 0 deletions common/eth2/src/lighthouse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ pub struct ProcessHealth {
pub pid_mem_resident_set_size: u64,
/// The total virtual memory used by this pid.
pub pid_mem_virtual_memory_size: u64,
/// The total shared memory used by this pid.
pub pid_mem_shared_memory_size: u64,
/// Number of cpu seconds consumed by this pid.
pub pid_process_seconds_total: u64,
}
Expand Down Expand Up @@ -277,6 +279,7 @@ impl ProcessHealth {
pid_num_threads: stat.num_threads,
pid_mem_resident_set_size: process_mem.rss(),
pid_mem_virtual_memory_size: process_mem.vms(),
pid_mem_shared_memory_size: process_mem.shared(),
pid_process_seconds_total: process_times.busy().as_secs()
+ process_times.children_system().as_secs()
+ process_times.children_system().as_secs(),
Expand Down
5 changes: 5 additions & 0 deletions common/warp_utils/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ lazy_static::lazy_static! {
"process_virtual_memory_bytes",
"Virtual memory used by the current process"
);
pub static ref PROCESS_SHR_MEM: Result<IntGauge> = try_create_int_gauge(
"process_shared_memory_bytes",
"Shared memory used by the current process"
);
pub static ref PROCESS_SECONDS: Result<IntGauge> = try_create_int_gauge(
"process_cpu_seconds_total",
"Total cpu time taken by the current process"
Expand Down Expand Up @@ -90,6 +94,7 @@ pub fn scrape_process_health_metrics() {
set_gauge(&PROCESS_NUM_THREADS, health.pid_num_threads);
set_gauge(&PROCESS_RES_MEM, health.pid_mem_resident_set_size as i64);
set_gauge(&PROCESS_VIRT_MEM, health.pid_mem_virtual_memory_size as i64);
set_gauge(&PROCESS_SHR_MEM, health.pid_mem_shared_memory_size as i64);
set_gauge(&PROCESS_SECONDS, health.pid_process_seconds_total as i64);
}
}
Expand Down

0 comments on commit 0c97762

Please sign in to comment.