replay: a frame's end line has the events and timestamp pools gauges, and on macOS the footprint

The live gauges of each frame's end line gain events and timestamp_pools; resident_bytes, read
from VmRSS on Linux, reads the process's physical footprint on macOS (proc_pid_rusage), which on
Apple's GPUs holds its GPU memory. For telling a stream's growth from a leak on the M3 against the
same stream on a discrete card.

Verified: cargo fmt; the M3 player build follows.
This commit is contained in:
Anees Iqbal committed 2026-11-18 12:02:50 -08:00
1 parent 04a4eaae9a
commit ec3468e9a8
2 files changed
+15

No files matched your search

@@ -2025,6 +2025,8 @@ impl Backend for NewRuntime {
("pipelines", gauges.pipelines),
("kernels", gauges.kernels),
("command_buffers", gauges.command_buffers),
("events", gauges.events),
("timestamp_pools", gauges.timestamp_pools),
("spilled_bytes", gauges.spilled_bytes),
("managed_spilled_bytes", gauges.managed_spilled_bytes),
("shared_idle_bytes", gauges.shared_idle_bytes),
@@ -477,7 +477,20 @@ fn covered(intervals: &mut [(u64, u64)]) -> u64 {
total
}
/// The process's resident memory in bytes: on macOS its physical footprint (`proc_pid_rusage`),
/// which on Apple's GPUs holds the process's GPU memory too.
#[cfg(target_os = "macos")]
fn resident_bytes() -> Option<u64> {
// SAFETY: `info` is a valid rusage_info_v4 for the call to fill, the flavour it names.
let mut info: libc::rusage_info_v4 = unsafe { std::mem::zeroed() };
let buffer = (&mut info as *mut libc::rusage_info_v4).cast::<libc::rusage_info_t>();
// SAFETY: as above; the process's own pid.
let read = unsafe { libc::proc_pid_rusage(libc::getpid(), libc::RUSAGE_INFO_V4, buffer) };
(read == 0).then_some(info.ri_phys_footprint)
}
/// The process's resident memory in bytes: `VmRSS` of `/proc/self/status`, where there is one.
#[cfg(not(target_os = "macos"))]
fn resident_bytes() -> Option<u64> {
let status = std::fs::read_to_string("/proc/self/status").ok()?;
let line = status.lines().find(|line| line.starts_with("VmRSS:"))?;