Expand description
§ergon-tune
Checks of a Linux host’s low-latency settings, for start-up and
housekeeping. A busy-spinning thread loses latency to whatever takes its
CPU: a timer tick, an interrupt, khugepaged, a busy hyperthread, a
container’s CPU quota. Each check reads the host and returns a
Finding: what is wrong, the exact fix and the evidence. Nothing is
changed, and no check needs more than the standard library and
rustix.
At start-up, name the CPUs that busy-spin and log what the checks find:
use ergon_tune::{Component, Host, HotSet, Role, t1_isolation, t3_thp};
let host = Host::system();
let hot = HotSet::new().with(3, Role::Loop); // the loop runs on CPU 3
for f in t1_isolation(&host, &hot).iter().chain(&t3_thp(&host, Component::Rt)) {
// One line each: `T1 warn: <what, its measured effect, the fix> (evidence: <where>)`.
if f.is_finding() {
eprintln!("{f}");
}
}Before deploying, run the same checks on a node with the ergon-tune
command (cargo install ergon-tune). Feature nic adds N1-N5.
§Documentation
- The ergon-tune book chapter: each setting in plain English, the evidence per check and a symptom-to-fix table.
- Crate README:
the
ERGON_HOST_CHECKSswitch, the guarantees and limits and the command’s options.
§The checks
| Check | Function | Meant for |
|---|---|---|
| T1 | t1_isolation | io, md, rt |
| T2 | t2_nic_irqs | io (egress NIC), md (data NICs, DPDK ports) |
| T3 | t3_thp | md, rt (warn); io (info) |
| T4 | t4_aeron_dir | md, rt |
| T5 | t5_numa_balancing | md, rt |
| T6 | t6_nic_node | md |
| T7 | t7_sched_policy | io, md, rt |
| T8 | t8_smt_siblings | io, md, rt |
| T9 | t9_cpu_quota at start; ThrottleWatch while running | io, md (start); ThrottleWatch: a runtime’s housekeeping |
| T10 | t10_smt_on | io, md |
| T11 | t11_time_sync at start; ClockWatch while running | rt (start, housekeeping) |
| T12 | t12_clocksource at start; ClockWatch while running | rt (start, housekeeping) |
| T13 | t13_workqueue_cpumask | io, md |
| T14 | t14_compaction (info) | io, md |
| T15 | t15_host_tasks | io, md |
| T16 | t16_instrumentation (info) | io, md |
| T17 | t17_ksm | io, md |
| T18 | t18_steal (info) | io, md |
| T19 | FaultWatch while running | io (the polling thread, every few seconds from housekeeping) |
| T20 | t20_irq_idle | a node check (the CPU taking NIC interrupts) |
| T21 | t21_tcp_autocorking | io (a warning: its connections send latency-sensitive TCP) |
| T22 | t22_aeron_affinity_names | md |
| T23 | t23_aeron_hugepage_env | md |
| T24 | t24_dpdk_nic_pair | io (on DPDK), md (on a DPDK port) |
| T25 | t25_frequency | a node check (the CPU frequency governor) |
| T26 | t26_family_layout | a caller that declares its instance family (c7i, c7a, c8g, c9g) |
| T27 | t27_ephemeral_overlap | a caller whose app listens on ports that may fall in net.ipv4.ip_local_port_range |
| K1-K6 | k8s_checks (with T7 and T9), inside a pod only | io |
| K7 | k8s_checks with Needs::with_nic | a caller that names its NIC |
N1 (nic) | n1_adaptive_rx | io, md (kernel sockets) |
N2 (nic) | n2_deferred_irqs | io, md |
N3 (nic) | n3_azure_vf | io |
N4 (nic) | n4_rx_ring | md (socket transport with busy polling) |
N5 (nic) | n5_irq_headroom | io, md (kernel sockets, with N1’s setting) |
- Callers (
Component): io is a busy-spinning network I/O layer, md an Aeron media driver, rt an application’s busy-spinning runtime. None of them is in this repository; each calls what it chooses. - Results: each is a
Finding. ItsStatussays whether the check fired; itsSeveritysays how to log it. - Cost: file reads and allocations. T7 reads
/proc/thread-self(no system call); T2 reads one directory and two files per interrupt; N1 and N4 make one netlink exchange per interface per reset (plus one family lookup on first use), each with 100 ms send and receive timeouts.ThrottleWatch::checkreads one open file (cpu.stattoo once throttling shows) and allocates only when it reports. T11 scans/procand waits at most 50 ms for chronyd;ClockWatch::checknever waits and allocates only when a finding changes. T15 reads two files per task on the host;FaultWatch::checkreads one open file and allocates only when it reports. - Evidence: each finding’s
evidencenames its source: the kernel’s, Kubernetes’ or a vendor’s documentation, marked “not measured here”. - The switch: every host-check warning line ends with how to silence
it.
HOST_CHECKS_ENVisoff(no warning line, the results are still returned),on(the default) orrequire(a warning is an error at start). SeeHostCheckPolicyandhost_check_line.
Structs§
- Bound
- A bound on
CLOCK_REALTIME’s error against UTC. - Busy
Poll - The host-wide kernel busy-polling settings.
- Chrony
Tracking - chronyd’s tracking report (
chronyc tracking), as it answered. - Clock
Bound Reading ClockBound’s bound, as of a read.- Clock
Sample - One check’s fresh reads: what
ClockWatch::checkreads, or what a test givesClockWatch::update. A plain value: no allocation. - Clock
Watch - T11 and T12 checked again from housekeeping, modelled on
ThrottleWatch. - Clocksource
- The kernel’s clock source and, for the fix, the CPU’s architecture and whether its TSC is invariant: what T12 judges. Build one to judge a host that is not here.
- Clocksource
Name - A clock source’s name held inline (at most 32 bytes, the kernel’s
CS_NAME_LEN), soClockWatchcompares a fresh read with nothing allocated. - Coalesce
- A NIC’s interrupt coalescing, as ethtool’s
COALESCE_GETreports it. - CpuCgroup
- This process’s CPU cgroup, as far as it can be seen from here.
- CpuQuota
- One cgroup’s CPU quota (its CFS bandwidth limit).
- CpuSet
- A set of CPU numbers. Its bitmap never ends in an empty word, so the derived equality is set equality.
- CpuSteal
- One CPU’s time since boot, from its
/proc/statline. - Dpdk
NicPair - The NIC the ENA device plugin granted this container.
- Ethtool
Cache - Ethtool answers per interface, valid while its index and
carrier_changesstay the same. - Fault
Watch - T19 while the loop runs: a hot thread’s page faults since the last check.
- Faults
- A task’s page faults since it started.
- Finding
- One result of a check.
- FsMagic
- A filesystem’s type, as
statfsgives it (f_type). - Host
- The host the checks read: its
/sysand/procunder a root. - HotCpu
- A CPU and what the component uses it for.
- HotSet
- The CPUs a component uses, with their roles. A CPU may appear with more than one role.
- Idle
State - One cpuidle state of a CPU (
/sys/devices/system/cpu/cpu<N>/cpuidle/state<i>). - Kernel
Sync - The kernel’s view of the wall clock:
adjtimexwithmodes0. - Needs
- What the caller does in the pod, so the checks warn only about the privileges and the layout it needs.
- Netlink
- Ethtool over generic netlink, unprivileged.
- NicIrq
- One interrupt of a NIC.
- Observed
- Everything read about the wall clock’s discipline, before judging it:
what a
TimeSyncProbeobserves, or a test’s fixture. - Platform
- The host’s architecture, vendor, cloud and instance type.
- PtpClock
- A PTP hardware clock:
/sys/class/ptp/<device>/clock_name. - Refclock
Id - A reference clock’s ID as chrony prints it (
UTI_RefidToString): the printable bytes of its four, in order. Held inline: no allocation. - Rings
- A NIC’s ring sizes, as ethtool’s
RINGS_GETreports them. - Throttle
Watch - T9 while the loop runs: this process’s cgroup’s throttling counters, read again to see whether the kernel stopped it since the last read.
- Throttling
- A cgroup’s throttling counters, from its
cpu.statandcpu.stat.local.None: not given here. - Time
Sync - How
CLOCK_REALTIMEis kept: the verdict, what keeps it, its error bound where known, and what was read. - Time
Sync Limits - What T11 warns over.
- Time
Sync Probe - What T11 asks and where (and what it warns over): the defaults read the running host; a test points them at fixtures and a fake chronyd.
Enums§
- Arch
- The CPU architecture, from
/proc/cpuinfo. - Bound
Source - Where an error bound came from.
- Cgroup
Version - The cgroup hierarchy the CPU controller is on.
- Chrony
Answer - What chronyd’s command port said. A plain value: no allocation.
- Chrony
Error - Why chronyd gave no tracking report. A plain value: making one allocates nothing.
- Chrony
Reference - What chronyd’s clock is synchronised to, from its tracking report.
- Clock
Bound Answer - What
ClockBound’s segment said. A plain value: no allocation. - Clock
Bound Error - Why
ClockBound’s segment could not be used. A plain value: making one allocates nothing. - Clock
Bound Status ClockBound’s clock status (ClockStatus).- Clocksource
Kind - What a clock source is to the hardware counter.
- Cloud
- The cloud, from the DMI system vendor.
- Component
- The component calling the checks. Some checks weigh differently per component (THP: a warning for the processes that run Aeron, information for a network I/O layer alone).
- CpuSet
Error - Why a CPU list or mask did not parse.
- Ethtool
Error - Why an ethtool query has no answer.
- Host
Check Error - What a caller does with a host-check policy or its report.
- Host
Check Policy - What
HOST_CHECKS_ENVis set to. - Nic
- A NIC, by kernel interface name or PCI address.
- Read
Error - Why something on the host could not be read. A check that meets one
reports
Status::Unknownwith it as the reason, never a warning. - Resume
Limit - A CPU’s resume latency limit (
pm_qos) (/sys/devices/system/cpu/cpu<N>/power/pm_qos_resume_latency_us). - Role
- What a hot CPU is used for.
- Sched
Policy - A scheduling policy, as
/proc/<tid>/statgives it. - Severity
- How a caller reports a
Status::Finding: a warning line, or an informational one. Opt-in strict modes (refusing to start) are the caller’s. - Status
- What a check found.
- Sync
Verdict - How
CLOCK_REALTIMEis kept, as far as this process can see. - Thread
- A thread whose policy or affinity is read.
- Time
Daemon - A time daemon recognised by its process name (
comm). - Vendor
- The CPU vendor, from
/proc/cpuinfo’svendor_id(x86) orCPU implementer(Arm).
Constants§
- AERON_
HUGEPAGE_ BYTES - Page size Aeron must be told when
AERON_DIRis on the plugin’s 2 MiB mount. - CPU_
LIMIT - The highest CPU number accepted, exclusive.
- HOST_
CHECKS_ ENV - The one switch over every host-check warning.
- SILENCE
- What every printed warning line ends with.
- T20_
MAX_ EXIT_ LATENCY_ US - The deepest exit latency (µs) T20 accepts on a CPU that takes a data
NIC’s interrupts: C1’s. On
intel_idleC1E (2 µs) is the first state past it.
Traits§
Functions§
- busy_
poll_ sysctls - Reads
net.core.busy_readandbusy_poll. They exist only in the host’s network namespace: in a pod they are absent, which is an error (unknown), never zero. - carrier_
changes - How many times
interface’s carrier has changed (/sys/class/net/<if>/carrier_changes): a re-check is due when it moves (an ENA reset brings the interface down and up). - cpu_
cgroup - This process’s CPU cgroup and the quotas on it and its parents visible here.
- cpu_
idle_ states - CPU
cpu’s cpuidle states, shallowest first; none when it has nocpuidledirectory. - cpu_
steal - Each CPU’s steal and total time since boot, from
/proc/stat. Read it twice and subtract to see the steal between the two reads. - cpuidle_
driver - The cpuidle driver (
intel_idle,acpi_idle,haltpoll), orNonewhen there is none (none, or a kernel without cpuidle: the hypervisor’s or the architecture’s idle, such as Graviton’s WFI). - fs_
magic - The filesystem
pathis on, or, if it does not exist yet (Aeron creates its directory), its nearest existing ancestor’s. - host_
check_ line - The one line of
fas the caller prints it:<prefix> warning: …withSILENCEon a warning,<prefix> info: …on an info finding or an unknown, and nothing on an ok. - in_pod
- Whether this runs inside a Kubernetes pod: the environment of the running
host, the service account mount, or a
kubepodscgroup path. - ip_
local_ port_ range - Reads
net.ipv4.ip_local_port_range: the range of ports the kernel hands to outgoing connections, both ends included. - ip_
local_ reserved_ ports - Reads
net.ipv4.ip_local_reserved_ports: the ports the kernel will not hand to an outgoing connection, as the sorted, merged ranges of the comma-separated list (single ports andlo-hiranges). - isolated_
cpus - The CPUs isolated from the scheduler’s load balancing.
- k8s_
checks - The checks that apply here: K1–K7, with T9 and T7 reused. Empty when this does not run inside a pod. Call this once, before the loop.
- n1_
adaptive_ rx - N1: ENA’s adaptive RX interrupt moderation is off on
interface. For kernel-socket paths on AWS, x86 and Graviton; other drivers are not checked. - n2_
deferred_ irqs - N2:
interface(and on Azure its VF) defers no interrupts when no socket on it busy-polls. - n3_
azure_ vf - N3: a
hv_netvscinterface (Hyper-V’s synthetic NIC) has an accelerated-networking VF (lower_*) that is up. Other drivers are not checked. - n4_
rx_ ring - N4: the kernel RX ring of
interface(on Azure its VF) holds at least min(4096, its maximum) entries. For the media driver’s socket transport with busy polling. - n5_
irq_ headroom - N5: with adaptive RX moderation off,
interface’s interrupts do not fire on a busy-spinning (receiver) CPU. - nic_
irqs - The interrupts of
nic’s PCI devices (an interface’s VFs included), in IRQ order: each device’smsi_irqs, or its legacyirqwhen that has a handler. - resume_
limit - CPU
cpu’s resume latency limit (pm_qos). - t1_
isolation - T1: each busy-spinning CPU of
cpus(Role::spins) is isolated from the scheduler’s load balancing,nohz_full, and outside/proc/irq/default_smp_affinity. - t2_
nic_ irqs - T2: no interrupt of
nicmay fire on a busy-spinning CPU ofcpus. - t3_thp
- T3: transparent hugepages are off, at every size.
- t4_
aeron_ dir - T4: the Aeron directory is on a memory-backed filesystem (tmpfs, hugetlbfs or ramfs). The media driver checks its own directory, a runtime the directory it connects to.
- t4_from
- T4 from a
fs_magicresult already taken. - t5_
numa_ balancing - T5: automatic NUMA balancing is off, on a host with more than one node.
- t6_
nic_ node - T6: on a host with more than one NUMA node,
nicis on the node of the busy-spinning CPUs ofcpus. The media driver’s check (a network I/O layer need not call it). - t7_
sched_ policy - T7:
thread, inrole, is not underSCHED_FIFOorSCHED_RR. The media driver checks its process before the agents start. - t8_
smt_ siblings - T8: no busy-spinning CPU of
cpusshares its physical core with another of the component’s threads. - t9_
cpu_ quota - T9: no CPU quota on this process’s cgroup, nor on a parent visible here.
- t10_
smt_ on - T10: SMT is off on this x86 host.
- t11_
time_ sync - T11: how
CLOCK_REALTIMEis kept, as findings (TimeSync::findings): the verdict always, and warnings for an unsettled clock, a wide error bound or a pending leap second. - t12_
clocksource - T12: the kernel’s clock source on
host(Clocksource::finding). - t13_
workqueue_ cpumask - T13: the unbound workqueue cpumask
(
/sys/devices/virtual/workqueue/cpumask) leaves out every busy-spinning CPU ofcpus(Role::spins). - t14_
compaction - T14: memory compaction leaves a hot thread’s pages in place.
- t15_
host_ tasks - T15: no task of another process may run on a busy-spinning CPU of
cpus(itsCpus_allowed_list, from/proc/<pid>/task/<tid>/status). - t16_
instrumentation - T16: no kernel instrumentation is loaded.
- t17_ksm
- T17: kernel same-page merging is not running (
/sys/kernel/mm/ksm/run0 or 2). - t18_
steal - T18: no time stolen from a busy-spinning CPU of
cpussince boot. - t20_
irq_ idle - T20: the CPUs that take the data NICs’ interrupts may not sleep deeper
than C1 (
T20_MAX_EXIT_LATENCY_US), and a hot CPU that is not busy-spinning is reported (information) when it may. - t21_
tcp_ autocorking - T21: TCP autocorking is off (
net.ipv4.tcp_autocorking0). - t22_
aeron_ affinity_ names - T22: no Aeron affinity setting is given by a name Aeron 1.54 no longer reads.
- t23_
aeron_ hugepage_ env - T23: a directory on hugetlbfs has the page size and non-sparse terms set.
- t24_
dpdk_ nic_ pair - T24: a process on DPDK has the device plugin’s NIC pair complete and consistent.
- t25_
frequency - T25: every online CPU with a cpufreq governor is in
performance. - t26_
family_ layout - T26: the host’s CPU layout matches the declared instance family, and
the pinning map
mapfits that layout. - t27_
ephemeral_ overlap - T27: no port an application listens on is one the kernel can hand to an outgoing connection.
- thread_
affinity - The CPUs
threadmay run on (Cpus_allowed_listof itsstatus). - thread_
policy - The policy of
thread: the 41st field of itsstat, counted after the command name (which may hold spaces and parentheses). - time_
sync - How
CLOCK_REALTIMEis kept onhostnow:TimeSyncProbe’s defaults. - unknown_
stops_ require - Whether an unknown result of check
idstops aHostCheckPolicy::Requirestart. - warn_
line - The one warning line of
f, if it is a warning:<prefix> warning: <the finding> (ERGON_HOST_CHECKS=off silences host-check warnings).