Back

It was not the hardware: how 37 audit rules ate 80% of my disk throughput

· 7 min read

It started with a night batch that failed.

We run two generations of bare-metal Kubernetes nodes:

  • newer nodes: AMD Zen 5, PCIe Gen5 NVMe SSDs
  • older nodes: AMD Zen 4, PCIe Gen4 NVMe SSDs

A staging Postgres primary switched over from a newer node to an older one. That night, the batch job ran out of CPU. I benchmarked both: the older node read from disk 2.5–4× slower and ran transactions ~5× slower.

Older hardware, slower machine. I wrote that down as the conclusion.

Then I checked the spec sheets.

The disks were barely working

Each older node has 2 to 6 SSDs in RAID 10, each rated at ~1M random-read IOPS. I measured with fio, the standard Linux disk benchmark: it fires reads at the disks from several parallel jobs and counts how many complete per second. On the older nodes, I got ~250k, whatever the number of disks:

older nodes, 4k random reads (1 █ ≈ 250k IOPS)

2 disks   rated  ████████                  ~2M
          got    █                         250k

6 disks   rated  ████████████████████████  ~6M
          got    █                         250k

If the disks were the limit, 6 disks would go ~3× faster than 2. Something above them capped everything at the same number.

Weirder: two older nodes with identical hardware (same board, BIOS, SSD model, firmware and kernel arguments) didn’t agree. Node A was stuck at 226k IOPS. Node B hit 850k.

Not the hardware.

Following the requests down the stack

My fio run had 8 parallel jobs, each keeping 32 reads in flight (queue depth 32): 256 requests on their way to the disks at any time. The node exporter gives read counts and read times for every layer of the stack, so you get the average latency at each one:

fio: 256 requests in flight
                     │
     ┌───────────────▼───────────────┐
     │ syscall (kernel, on CPU)      │ ◄─ where are the
     └───────────────┬───────────────┘    other 236?
                     │ actually in flight:
                     │ node A ≈ 20, node B ≈ 76
     ┌───────────────▼───────────────┐
     │ ext4                   85 µs  │
     │ LVM                    85 µs  │
     │ dm-crypt (LUKS)        85 µs  │
     │ md RAID 10             85 µs  │
     │ NVMe                   85 µs  │
     └───────────────────────────────┘
       same latency on both nodes

Every layer answers in ~85 µs on both nodes, matching the drive spec. Only the number of requests in flight differs. Little’s law does the rest:

throughput = requests in flight / latency

node A   20 / 85 µs  ≈ 235k IOPS   (measured 226k)
node B   76 / 85 µs  ≈ 890k IOPS   (measured 850k)

The requests weren’t waiting on the disk. Most of them never reached it.

The CPU agrees: each I/O cost fio 20–28 µs of CPU on the older nodes, vs 3.5 µs on the newer ones. A CPU generation explains ~25% of that, not 6–8×. fio wasn’t throttled or blocked, just burning time in the kernel.

What perf saw

Top kernel functions on node A during a read-only fio run: audit_filter_rules, audit_exe_compare, get_mm_exe_file, get_file_rcu, audit_comparator. None of them on node B.

That’s the Linux audit subsystem. Node A had 43 rules loaded, 37 of them with this shape:

-a always,exit -F arch=b64 -S execve -F euid=0 -F key=rootcmds    # log commands run as root
-a never,exit  -F arch=b64 -S all -F exe=/opt/bin/runc             # ...but not runc
-a never,exit  -F arch=b64 -S all -F exe=/opt/cni/bin/calico       # ...nor Calico
# 37 rules of this shape: containerd, CNI plugins, iptables, mount, lvm

The intent: log root commands, skip the noisy container and network tooling. What the kernel actually does:

any syscall exits, in any process on the node
  │
  ▼
for each of the 37 "-S all -F exe=" rules:
  │  exe = get_mm_exe_file(mm)      ◄─ atomic ref++ (shared)
  │  exe == rule path ?
  │      runc:     yes → stop
  │      postgres: no  → next rule
  │  fput(exe)                      ◄─ atomic ref-- (shared)
  ▼
postgres: 37 lookups, 74 atomics, on every single syscall
  • -S all: the rules are checked on every syscall, not just execve.
  • -F exe=: each check takes a reference on the caller’s executable file.
  • That file is shared by all threads of a process, and by processes forked without exec, like Postgres backends:
postmaster ─fork─┬─► backend 1 ─┐
                 ├─► backend 2 ─┼─► one shared file,
                 └─► backend N ─┘   one refcount for all CPUs

Same for fio, ClickHouse, a JVM. They contend on one counter. CPU burns, nothing blocks. And every disk read is at least one syscall: hence the 20 µs per I/O, and a ceiling that ignores the number of disks.

The irony: these are never rules, meant to reduce noise. runc matches its rule and stops early. Postgres matches none and pays for all 37.

A case of config drift

The rules came out of the same hardening work as SELinux, but SELinux was permissive and loads no rules of its own. These were plain kernel audit rules, applied by hand on the older nodes from a draft in our provisioning repo:

              repo              older nodes     newer nodes
early 2025    draft, disabled   applied by hand
months later  draft removed     still ACTIVE    empty file
                                → slow          → fine

The draft left the repo, not the servers, and nothing compared the two. And node B, the fast “identical” node? Same active file, but the service loading the rules had failed at its last boot. Fast by accident, until its next reboot.

Total: 15 of our 43 bare-metal nodes, 7 of them in production.

The fix, and the numbers

Empty the rules file, reload the rules. No reboot, no drain, ~10 s per node.

Staging node C, read-only fio before and after:

Test (4k random reads)With the rulesWithoutGain
Raw RAID, 8 jobs × QD32217k IOPS1.09M IOPS×5.0
Through dm-crypt, same load222k IOPS941k IOPS×4.2
Single thread, QD1 latency63 µs58 µs−8%

Single-request latency barely moves: the disk dominates. The rules cost throughput under concurrency, which is what databases do.

Whole fleet, night before vs night after:

15 h average, cleaned nodesBeforeAfterChange
Kernel CPU132 CPUs76 CPUs−56 CPUs (−43%)
Application CPU569 CPUs584 CPUs+2.6% (same work)
Postgres kernel CPU13.1 CPUs5.5 CPUs−58%

Untouched nodes stayed flat. 56 CPUs of pure overhead, gone.

The older nodes are still somewhat slower than the newer ones: that part really is hardware. But the 4–5× gap I was ready to blame on “old hardware” was mostly self-inflicted.

What that remaining gap really costs, and why, is the next post.

How I worked on this with Claude

Claude, Anthropic’s coding agent, ran in my terminal with read-only access to our metrics, logs and clusters.

  • It disagreed with me. Asked to confirm “it’s the hardware”, it put the SSD specs next to my measurements: an identical ceiling on 2 and 6 disks can’t be the disks.
  • It did the tedious part fast. Per-layer latency, Little’s law, CPU per I/O on a dozen nodes, BIOS/firmware/kernel/governor diff between A and B. Ten minutes of PromQL each for me, a few minutes for all of it.
  • It dropped wrong leads fast. IOMMU mode, AES driver, CPU mitigations, crypto bottleneck: one read-only check each, then gone.
  • It connected the dots. audit_exe_compare in perf → exe= rules on every syscall → git log -S in the provisioning repo to find the draft and its removal.
  • The guardrails held. Debug pods, fio on production, removing the rules: all blocked. It handed me the command, the impact and the rollback. After last time, that’s the split I want: it thinks, I press the buttons.

Question to root cause: one afternoon. Fleet cleanup and numbers: the next morning. My first, classic two-day benchmark round had produced the wrong conclusion.

What I take away from this

  • Check the obvious explanation against the specs. A ceiling that doesn’t scale with the disks is never the disks.
  • Measure per layer before blaming a component. Latency plus requests in flight shows where the time goes.
  • A never rule still costs the check. Per-syscall exe= rules hurt multi-threaded and forking programs most. Go run auditctl -l on your database hosts.
  • Config drift is invisible until it costs you. The active rules only lived on the servers. If it’s on a server, it belongs in a repo, with something checking that the two agree. We manage almost everything as code now; this file was a leftover from before.

Next time a machine is “just old”, check the spec sheet. It might be worth 56 CPUs.