Topic · 26 articles
Tracing & Performance
The dashboard says the box is fine. The box disagrees. Tracing is how you ask the kernel directly instead of trusting whatever an agent decided to sample, and every tool on this page ships with the OS or one package away from it.
Start with strace used properly, as a counter and not a firehose, and the by-hand walk through /proc for a wedged process. Then bpftrace and dtrace for the questions strace can't answer, perf for CPU, and ftrace for when you need the kernel's own call graph. The Tales are what this looks like at 3am.
Start here
Read these first, in this order.
- 01

Tip · 2026-08-13
strace -c is a profiler. Stop spraying and praying.
Most people open strace, get buried in output, and close the terminal. Four flags fix that: -c counts, -e filters, -P follows a single path, -T times each call. Here is how strace is actually supposed to work.
- 02

Tip · 2026-08-06
Read a wedged process with your hands, not a dashboard
A process is hung and the graphs won't say why. Here's the /proc, ps, strace, and dmesg walk that finds a stuck worker in about ninety seconds, no agent, no vendor, no login.
- 03

Tip · 2026-08-16
bpftrace gives Linux what FreeBSD had in 2005. The one-liners are worth the wait.
dtrace showed up on Solaris in 2004, shipped in FreeBSD 7 in 2008, and Linux users spent the next decade pretending strace was sufficient. bpftrace is the real answer, doing dynamic kernel tracing, histograms, stack walks, zero overhead when idle.
- 04

Tip · 2026-07-27
Get a real disk latency histogram in one line of bpftrace
iostat gives you an average, and averages hide the tail that's actually hurting you. A four-line bpftrace program prints a log2 histogram of block I/O latency per device, live, on a production box, with no agent and no restart.
- 05

Tip · 2026-07-20
Find out which syscall is actually eating your latency with one dtrace one-liner
A real dtrace/bpftrace one-liner for finding the syscall responsible for tail latency, plus why strace -T won't get you there.
- 06

Tip · 2026-08-14
Your kernel ships a CPU profiler. perf(1) is the key.
perf stat hands you hardware performance counters (cycles, cache misses, branch mispredictions) in seconds. perf record samples call stacks at full speed. Both are already installed and beat any SaaS APM for understanding CPU-bound problems.
- 07

Tip · 2026-08-22
ftrace has been on your machine since 2.6.27. Here's how to actually use it.
ftrace is Linux's built-in kernel function tracer, accessible directly via /sys/kernel/debug/tracing/. No compiler, no LLVM, no kernel headers: write to files, read call graphs. Here's the workflow for function tracing, call-graph timing, IRQ latency, and isolated trace instances.
The syscalls underneath
Version introduced, sourced from the man page. Full cards in the syscall reference, or check your kernel.
| Interface | Since | What it does |
|---|---|---|
| sched_setaffinity(2) | Linux 2.5.8 | Set the set of CPUs a thread may run on (taskset is the CLI wrapper). |
| ioprio_set(2) | Linux 2.6.13 | Set a thread's I/O scheduling class and priority (ionice is the CLI wrapper). |
| futex(2) | Linux 2.6.0 | Fast userspace locking: wait on or wake threads sleeping on a 32-bit word in memory. |
| rseq(2) | Linux 4.18 | Register a per-thread struct that the kernel keeps updated with the current CPU ID, enabling lock-free per-CPU data updates via restartable critical sections. |
| perf_event_open(2) | Linux 2.6.31 | Open a file descriptor for a hardware or software performance counter. |
| process_vm_readv(2) | Linux 3.2 | Read from or write to another process's virtual address space in one syscall, without attaching via ptrace. |
| sched_setattr(2) | Linux 3.14 | Set scheduling policy and attributes for a thread, including SCHED_DEADLINE runtime/deadline/period reservations. |
More console tips (10)
- gstat shows which disk is lying to you, and %busy is not what you think
- zpool iostat -l and -w: read pool latency, not just throughput
- ktrace, kdump and truss: tracing syscalls on FreeBSD without dtrace
- PSI: /proc/pressure tells you a box is dying before load average does
- SCHED_DEADLINE: ask the kernel for a CPU budget and get told no
- process_vm_readv(2): read another process's memory without stopping it
- perf_event_open(2): hardware counters without the wrapper
- ss -i shows you what netstat never could: TCP internals live
- taskset pins a process to specific CPUs. numactl keeps its memory local too.
- Stop your backup job from taking production down with it
Rod's tales (4)
- The bug was gone the moment I looked for it.
- The code ran in three milliseconds and the request took two hundred
- The load was forty and the box was idle
- The observability platform was down during the outage. Good. Now do it with your hands.
MOTD (5)
- Linux 7.3 is out. The PCIe Gen5 NVMe bottleneck fix is the part worth reading.
- FreeBSD 15.1 lets you swap schedulers at boot. No recompile.
- mold links Chromium in two seconds. Your build chain is still waiting on the linker.
- An ARM engineer let an AI generate hideous code and found a 70% speedup in the Linux kernel build
- You can write a CPU scheduler in BPF now. Most of you shouldn't. Some of you really should.