1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
//! # 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](https://crates.io/crates/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](https://mimran1980.github.io/ergon/tune/overview.html):
//! each setting in plain English, the evidence per check and a
//! symptom-to-fix table.
//! - [Crate README](https://github.com/mimran1980/ergon/blob/main/tune/README.md):
//! the `ERGON_HOST_CHECKS` switch, 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`]. Its [`Status`] says whether the check
//! fired; its [`Severity`] says 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::check`] reads one open file (`cpu.stat` too once
//! throttling shows) and allocates only when it reports. T11 scans
//! `/proc` and waits at most 50 ms for chronyd; [`ClockWatch::check`]
//! never waits and allocates only when a finding changes. T15 reads two
//! files per task on the host; [`FaultWatch::check`] reads one open file
//! and allocates only when it reports.
//! - **Evidence**: each finding's `evidence` names 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_ENV`] is `off` (no warning line, the results are
//! still returned), `on` (the default) or `require` (a warning is an error
//! at start). See [`HostCheckPolicy`] and [`host_check_line`].
pub use ;
pub use ;
pub use ;
pub use ;
pub use t26_family_layout;
pub use ;
pub use ;
pub use t25_frequency;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use t21_tcp_autocorking;
pub use ;