spdl.pipeline.SystemStats

class SystemStats(timestamp: float, interval: float, root_pid: int, processes: list[~spdl.pipeline._sys_monitor.ProcessStats], threads: list[~spdl.pipeline._sys_monitor.ThreadStats], cgroup: ~spdl.pipeline._sys_monitor.CgroupStats | None, host_pressure: dict[str, ~spdl.pipeline._sys_monitor.PressureStats | None] = <factory>, sample_time: float = 0.0, backend: str = 'python')[source]

One sample of SystemMonitor.

Added in version 0.9.0.

Methods

summary([top_threads])

Aggregate the sample into one compact, JSON-serializable record.

to_dict()

Convert to a JSON-serializable dictionary with every process and thread group.

Attributes

backend

which reader collected the sample.

sample_time

Seconds spent collecting this sample.

timestamp

Wall-clock time of the sample (seconds since the epoch).

interval

Seconds since the previous sample.

root_pid

The process whose family is monitored.

processes

The root process and its descendants.

threads

Threads of the processes, grouped by process and name.

cgroup

The monitoring process's cgroup, or None if it cannot be read.

host_pressure

Host-wide PSI (/proc/pressure) for "cpu", "memory" and "io".

backend: str = 'python'

which reader collected the sample.

Type:

"native" or "python"

cgroup: CgroupStats | None

The monitoring process’s cgroup, or None if it cannot be read.

host_pressure: dict[str, PressureStats | None]

Host-wide PSI (/proc/pressure) for "cpu", "memory" and "io".

interval: float

Seconds since the previous sample. Counters are increases over this interval.

processes: list[ProcessStats]

The root process and its descendants.

root_pid: int

The process whose family is monitored.

sample_time: float = 0.0

Seconds spent collecting this sample.

summary(top_threads: int = 8) → dict[str, object]

Aggregate the sample into one compact, JSON-serializable record.

Counters are summed over the processes; minflt_per_process gives the spread of minor faults over the processes other than the root, which shows a split between workers; top_threads thread groups are merged by name, without a trailing index, across processes and ranked by CPU time. The cgroup and host pressure are included as they are. The record is about 2 KB, independent of the number of processes and threads.

rss_anon sums each process’s resident anonymous memory, which counts pages that forked processes still share once per process. The cgroup’s memory_anon is the deduplicated total.

Parameters:

top_threads – The number of thread groups to include.

threads: list[ThreadStats]

Threads of the processes, grouped by process and name. Empty with threads=False.

timestamp: float

Wall-clock time of the sample (seconds since the epoch).

to_dict() → dict[str, object]

Convert to a JSON-serializable dictionary with every process and thread group.

This is the full detail, tens of kilobytes for a process family with many threads. For a log line or a table row per interval, use summary().