Skip to main content

Module stats

Module stats 

Source
Expand description

Stats server, #[derive(Stats)] metrics and monitor loop.

Metrics corresponds to the BPF-side struct mlfq_stats: the type is defined in src/bpf/intf.h and the volatile instance lives in src/bpf/main.bpf.c, plus a userspace uptime gauge. Field names match the BPF struct 1:1. The top stats op reports deltas over the poll interval.

Re-exportsยง

use std::io::Write; ๐Ÿ”’
use std::sync::Arc; ๐Ÿ”’
use std::sync::atomic::AtomicBool; ๐Ÿ”’
use std::sync::atomic::Ordering; ๐Ÿ”’
use std::time::Duration; ๐Ÿ”’
use anyhow::Result; ๐Ÿ”’
use scx_stats_derive::Stats; ๐Ÿ”’
use scx_stats_derive::stat_doc; ๐Ÿ”’
use serde::Deserialize; ๐Ÿ”’
use serde::Deserialize; ๐Ÿ”’
use serde::Serialize; ๐Ÿ”’
use serde::Serialize; ๐Ÿ”’
use scx_stats::prelude::*; ๐Ÿ”’

Structsยง

Metrics
PerCpuMetrics
One entry of the web UIโ€™s per-CPU card grid.
WebMetrics
Snapshot served by the web UIโ€™s /api/stats endpoint.

Constantsยง

OP_LAT_EDGES_US ๐Ÿ”’
Bucket edges of the op-latency histogram, matching enum mlfq_op_lat_consts in src/bpf/intf.h, in microseconds.

Functionsยง

fmt_op_lat ๐Ÿ”’
Format one opโ€™s eight bucket counts with their microsecond edges as โ€œlow-high=countโ€ pairs. A histogram shorter than eight buckets (the untracked default) formats as โ€œn/aโ€.
monitor
The monitor loop. It periodically polls the stats server and prints a one-line summary. It runs in its own thread (see main.rs) and exits on shutdown.
server_data
The stats server definition. A single top op reporting interval deltas.