Skip to content

Commit 0c97762

Browse files
authored
Track shared memory in metrics (sigp#5023)
* Track shared memory so we can exclude them form resident memory. * Bump psutil version to 3.3.0 to get shared memory metrics.
1 parent 01994c4 commit 0c97762

File tree

4 files changed

+18
-32
lines changed

4 files changed

+18
-32
lines changed

Cargo.lock

Lines changed: 9 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/eth2/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pretty_reqwest_error = { workspace = true }
3636
tokio = { workspace = true }
3737

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

4242
[features]

common/eth2/src/lighthouse.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ pub struct ProcessHealth {
243243
pub pid_mem_resident_set_size: u64,
244244
/// The total virtual memory used by this pid.
245245
pub pid_mem_virtual_memory_size: u64,
246+
/// The total shared memory used by this pid.
247+
pub pid_mem_shared_memory_size: u64,
246248
/// Number of cpu seconds consumed by this pid.
247249
pub pid_process_seconds_total: u64,
248250
}
@@ -277,6 +279,7 @@ impl ProcessHealth {
277279
pid_num_threads: stat.num_threads,
278280
pid_mem_resident_set_size: process_mem.rss(),
279281
pid_mem_virtual_memory_size: process_mem.vms(),
282+
pid_mem_shared_memory_size: process_mem.shared(),
280283
pid_process_seconds_total: process_times.busy().as_secs()
281284
+ process_times.children_system().as_secs()
282285
+ process_times.children_system().as_secs(),

common/warp_utils/src/metrics.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ lazy_static::lazy_static! {
1414
"process_virtual_memory_bytes",
1515
"Virtual memory used by the current process"
1616
);
17+
pub static ref PROCESS_SHR_MEM: Result<IntGauge> = try_create_int_gauge(
18+
"process_shared_memory_bytes",
19+
"Shared memory used by the current process"
20+
);
1721
pub static ref PROCESS_SECONDS: Result<IntGauge> = try_create_int_gauge(
1822
"process_cpu_seconds_total",
1923
"Total cpu time taken by the current process"
@@ -90,6 +94,7 @@ pub fn scrape_process_health_metrics() {
9094
set_gauge(&PROCESS_NUM_THREADS, health.pid_num_threads);
9195
set_gauge(&PROCESS_RES_MEM, health.pid_mem_resident_set_size as i64);
9296
set_gauge(&PROCESS_VIRT_MEM, health.pid_mem_virtual_memory_size as i64);
97+
set_gauge(&PROCESS_SHR_MEM, health.pid_mem_shared_memory_size as i64);
9398
set_gauge(&PROCESS_SECONDS, health.pid_process_seconds_total as i64);
9499
}
95100
}

0 commit comments

Comments
 (0)