Apple GPUs on macOS, with their own struct and target. Utilization and
memory in use come from the accelerator's PerformanceStatistics in the
IORegistry, and memory total is the host's. Power, the Neural Engine's
power and the graphics clock come from one IOReport delta per poll, so
Metal sets two_readings. Temperature, fans and the system power come
from the SMC. Processes are the GPU's clients, with their GPU time.
Metal also measures the host: CPU power from the same IOReport delta,
from the PMP histograms once the Energy Model reads 0 for the CPU, as on
macOS 27, and system power from the SMC.
CoreFoundation, IOKit and IOReport are opened by install name, since the
hermetic toolchain has nothing to link against. The IOReport, SMC and
GPU time readers are ported from mactop v2.1.6 (MIT).
The macOS host adds user, command, CPU and RSS to the local rows, from
libproc. The user and the executable path of every process can be read;
the CPU and RSS of another user's process read 0 unless zml-smi runs as
root. CPU share is CPU time over elapsed time times the number of CPUs,
in tenths of a percent, as on Linux.
A platform with a host entry fills CPU and system power in its own task.
The host step copies what it measured, starting each round from what the
host read once, so a value not measured this round is null.
FuriosaAI RNGD chips through sysfs, one device per chip, with the paths, units
and formulas of furiosa-smi-go 2026.4.0: utilization from the task and total
cycle counts of the cores, memory in use from the groups of fused cores, power
and temperatures from hwmon, governor, liveness and throttle reasons as codes,
and one process row per process and chip from the holders of /dev/rngd.
One file, Neuron.zig, replaces nrt.zig, metrics.zig and process.zig. A
device is a core. libnrt is opened from the sandbox with openBundled,
and its private ndl and nds functions are found in its ELF symbol table
from the address of an exported one.
Each round lists the apps of each chip once: utilization sums the
growth of one busy-time counter per process and core, where it used to
take the growth of a sum that drops when a process exits, and the same
scan gives the process rows. Memory in use of a core is read once per
chip, the sum over its cores, instead of once per core. An idle chip
now shows 0, and a chip whose apps cannot be read shows no
utilization instead of its last value.
AMD GPUs through the bundled libamd_smi: sockets and processors
enumerated in init, sentinel values read as null, the process list
called with stderr pointed at the null device. Memory per process is
the VRAM of its fdinfo files on the GPU; utilization per process is one
counter per process and GPU over graphics plus encode time.
pcie_bandwidth_mbps is the line rate of the PCIe generation times the
width, since the current speed amdsmi reports stays at 2.5 GT/s on an
R9700 whose link runs at 32 GT/s.
platforms.zig lists the platform files of each OS and architecture.
main opens the platforms whose detect is true and the remote hosts,
skips those that fail to open, and runs one output.
AMD, Neuron and TPU have their directory, BUILD target, registry line
and select entry, with a platform whose detect is false until they are
ported.
std's unexpected errno traces are off: a /proc file can vanish between
its open and its read, which printed stack traces in debug builds.
One file, OneApi.zig, replaces monitor.zig, oneapi.zig, metrics.zig and
process.zig, on top of the sysfs, hwmon, pci, fdinfo and FdHolders
blocks. hwmon file names are chosen once in init.
Each round scans the DRM clients once, where every metric used to scan
/proc on its own, and reads only the fdinfo of descriptors that point
into /dev/dri. A file that vanished between its open and its read is
skipped. Utilization keeps one counter per process instead of summing
running totals that drop when a process exits: busy time per engine
class for i915, busy cycles over total cycles for xe.
pcie_bandwidth_mbps is now the line rate of the link in megabits per
second, 512000 on a gen 5 x16 link, where it was megabytes per second
after encoding.
One file, Nvml.zig, replaces nvml.zig, metrics.zig and process.zig:
init finds the GPUs, poll assigns each field from the call that reads
it, and processes reads the running processes and their utilization.
Functions that return a status are Checked, with two errors instead of
thirty, and size queries go through the raw status.
PCIe throughput is still read every fourth poll. pcie_bandwidth_mbps is
now the lane speed times the link width, as on every platform.
The card, the history and the detail page switch on the sample, with
one prong for the GPU targets, so a new target that is not added to
them does not compile. Titles show the driver version and the details,
the card only those marked for its title. Logos are kept by target.
The process table copies the merged rows, and their strings, into its
frame while it holds their lock.
Every output reads the device table and the latest samples by
reflection, so no field is named by a string.
JSON writes each device as {"device": ..., "sample": {"<target>": ...}},
which is also what --remotes reads. CSV keeps one table per target and
leaves out a device column that is empty for the whole table. The CUDA
version becomes the detail cuda_version.
Prometheus has one literal per struct with an entry per field, and
writes metric by metric, so names, labels and family order are
unchanged. PCIe throughput is kilobytes per second, now multiplied by
1000 instead of 128.
The API and Prometheus servers share one loop, and write each body to
memory before sending it.
zml-smi/smi, imported as "zml-smi", replaces info, collector and utils.
A device is written once and a sample is a union keyed by its target:
named ?u64 fields in one unit each, no strings. Platforms implement
smi.Platform, an interface with one batch poll and an optional process
list per interval, over samples that start empty.
The collector owns the tasks, the global device indices and the
snapshots: one task per source, a host task that merges and enriches
the process rows once per round, and one round (two when a source
derives values from two polls) for the one-shot outputs. Remote hosts
are sources too: their fetch races a timer, and their devices are
matched by row, target and name.
The blocks the platforms share, each with its tests: sysfs reads into
caller buffers through directories kept open, hwmon, pci, fdinfo,
FdHolders, dynlib with Checked, units and Counter.
The platforms are rewritten against a new core, one file each. The new
file names differ from the old ones only by case, which the case-insensitive
checkouts mirrored to the build boxes cannot hold side by side. The ports
read the old sources from history.
The terminal stretches an image over the cells it is given, so rounding
the width up widened icons by up to a cell. The image tests now run as
part of the tui test target, which was running none.
Charts plot one sample per braille dot, but the history was capped at 500
samples: a chart wider than 250 cells never reached its left edge. The
history now holds two samples per column of the widest terminal seen.
Processes were enriched by whoever read them: on every API request, from
every connection at once, and on every TUI draw. That raced on the
enricher and made CPU usage a delta over an arbitrary window.
A poll of the collector now merges and enriches them once per interval,
and the API, the TUI and --json read its result.
amdsmi reports the time a process spent on the GFX and ENC engines as a
running total in ns, which was cast to u16 as if it were a percentage.
Utilization is now its growth between two polls over the elapsed time.
One-shot runs sample once beforehand, as neuron does.
2026-11-12 19:59:45 +01:00
173 changed files with 9089 additions and 8646 deletions