Expand description
The GPU’s use and memory, for the status bar’s GPU meter and its panel (SPEC_STATUS_BAR_GPU_PANEL_2026_11_15.md).
One sampler, and it is srv’s: GpuSampler::global holds the one open set of counters. The status bar’s
compact figure asks it every few seconds from the telemetry thread (CompactPoller); the panel asks it every
two seconds while it is open (gpu.sample). A read newer than the asker’s reuse window is handed back instead
of made again, so two askers never read twice in a row. Per-process names are not made here: the panel’s handler
takes them from Tower’s own sample, which is the one place that names a process.
Cost: reading the counters is the cost, so it is bounded. A read that takes longer than its budget
(Budget) widens the interval to the next read, and the panel’s footer says so; reads never run back to back.
cost_tests measures a read (run in CI, and on a machine of its own: cargo test -p agentmux-srv-core gpu::cost -- --ignored --nocapture).
Windows reads the PDH counters (pdh). Linux reads what the kernel and the driver publish (linux: AMD’s sysfs files,
NVIDIA through NVML loaded at run time, fdinfo for the processes, Intel’s memory only). macOS is a later phase and
reports GpuSampleState::Unsupported.
The panel lists real GPUs only, on every OS, decided by what the OS says an adapter is and never by its name.
Windows asks the kernel’s adapter type (aggregate::AdapterType) and drops an indirect display device, an adapter that
cannot render, and the software renderer; Linux lists the PCI bus’s display controllers, so a virtual DRM device is
never a row (linux). A macOS reader, when it is written, must list only the devices Metal itself reports as GPUs
and treat anything else the same way. Everywhere the one adapter a machine has is shown, however virtual.
Modules§
- aggregate
- A read of the GPU counters, made into what the status bar and the panel show: per adapter its use and memory, per process its use and memory. Pure: the counters’ instances in, figures out, so every case (several adapters, an adapter no process uses, a counter set the machine lacks) is a test on any platform.
- drm
- The text Linux gives about its GPUs, parsed (SPEC_STATUS_BAR_GPU_PANEL_2026_11_15.md §3, phase 2): a process’s
/proc/<pid>/fdinfo/<fd>for a DRM device (kernel 5.14 and later; amdgpu, i915, xe), theueventof a card, and the PCI id database’s names. Pure text and arithmetic, so every case is a test on any platform;linux.rsreads the files. - names
- The names Windows gives the instances of its GPU performance counters, parsed. They carry the process, the adapter and the engine, which is all the per-process and per-adapter figures are made from (SPEC_STATUS_BAR_GPU_PANEL_2026_11_15.md §3):
Structs§
- Budget
- An interval that stretches when a read costs too much and comes back when it doesn’t.
- Compact
- The status bar’s two figures: the busiest adapter’s use, and the fullest adapter’s memory, percent.
- Compact
Poller - The telemetry tick’s view of the sampler: asks it every
COMPACT_EVERY(stretched when reads are slow) and keeps the answer for the ticks between. - GpuSampler
- The one open set of GPU counters (module doc).
- Memory
Limits - The most one process can hold: the biggest adapter’s dedicated memory and the most shared memory the OS lets the GPU
have.
Nonewhere the adapters said nothing, so nothing is dropped. - Named
- What Tower knows of a process by its id: an image name, and for AgentMux’s own what it is.
- Sample
- A read, as the sampler hands it out.
Constants§
- COMPACT_
EVERY - How often the status bar’s figure is read, and the longest it is stretched to.
- OTHERS_
LISTED - The biggest other users of the GPU that are listed by name.
- PANEL_
EVERY - How often the open panel is read, and the longest it is stretched to.
- READ_
BUDGET - A read slower than this widens the interval to the next one.
Functions§
- add_
compact_ values - Puts the status bar’s GPU figures,
gpuandgpu:mem, in a telemetry tick’s values: read every few seconds by the one sampler (module doc) and repeated in the ticks between. Nothing is put in while nothing is readable, so the meter is hidden, not shown as 0%. - compact_
of - The status bar’s figures from a read;
Nonewhen no adapter’s use is known (nothing readable: the meter is hidden, not shown as 0% or an error). - shape_
processes - The rows of the panel: AgentMux’s own processes and the biggest
OTHERS_LISTEDothers, sorted by use and then memory (AgentMux’s first where those are equal), and the rest of the others added up.