diff options
| author | Paul Buetow <paul@buetow.org> | 2026-04-30 14:03:58 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-04-30 14:03:58 +0300 |
| commit | aa97bf21c131e06a601123901baf48285e62424c (patch) | |
| tree | ae85e040af91c7f2e724f5214217109193ed99ca /gemfeed | |
| parent | 1bd922e9f8df51a333ebf46a4ca0080349fec64e (diff) | |
Update content for html
Diffstat (limited to 'gemfeed')
18 files changed, 641 insertions, 0 deletions
diff --git a/gemfeed/DRAFT-ior-guided-tour.html b/gemfeed/DRAFT-ior-guided-tour.html new file mode 100644 index 00000000..6acc3bc7 --- /dev/null +++ b/gemfeed/DRAFT-ior-guided-tour.html @@ -0,0 +1,255 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<title>I/O Riot NG: a guided tour</title> +<link rel="shortcut icon" type="image/gif" href="/favicon.ico" /> +<link rel="stylesheet" href="../style.css" /> +<link rel="stylesheet" href="style-override.css" /> +</head> +<body> +<p class="header"> +<a href="https://foo.zone">Home</a> | <a href="https://codeberg.org/snonux/foo.zone/src/branch/content-md/gemfeed/DRAFT-ior-guided-tour.md">Markdown</a> | <a href="gemini://foo.zone/gemfeed/DRAFT-ior-guided-tour.gmi">Gemini</a> | <a href="https://snonux.foo">Microblog</a> | <a href="https://irregular.ninja">Street photography</a> +</p> +<h1 style='display: inline' id='io-riot-ng-a-guided-tour'>I/O Riot NG: a guided tour</h1><br /> +<br /> +<span class='quote'>Draft — not in the gemfeed yet. Promote with the usual rename + index dance.</span><br /> +<br /> +<span>I rewrote I/O Riot. The old one was C + Systemtap and dates from 2017. The new one — call it ior — is Go + C + BPF via libbpfgo, runs on Linux, and is mostly a TUI dashboard rather than a record/replay box. Since pictures are worth more than yet another README table of key bindings, I built a demo.</span><br /> +<br /> +<pre> + .---. + / \ + \.@-@./ + /`\_/`\ + // _ \\ + | \ )|_ + /`\_`> <_/ \ +jgs\__/'---'\__/ +</pre> +<br /> +<a class='textlink' href='https://codeberg.org/snonux/ior'>I/O Riot NG on Codeberg</a><br /> +<a class='textlink' href='./2018-06-01-realistic-load-testing-with-ioriot-for-linux.html'>the original I/O Riot post (2018)</a><br /> +<br /> +<h2 style='display: inline' id='table-of-contents'>Table of Contents</h2><br /> +<br /> +<ul> +<li><a href='#io-riot-ng-a-guided-tour'>I/O Riot NG: a guided tour</a></li> +<li>⇢ <a href='#what-it-does'>What it does</a></li> +<li>⇢ <a href='#a-short-detour-ebpf-and-libbpfgo'>A short detour: eBPF and libbpfgo</a></li> +<li>⇢ <a href='#the-whole-thing-as-a-tape-pipeline'>The whole thing as a tape pipeline</a></li> +<li>⇢ <a href='#first-launch'>First launch</a></li> +<li>⇢ <a href='#the-seven-tabs-in-30-seconds-each'>The seven tabs, in 30 seconds each</a></li> +<li>⇢ <a href='#the-stream-tab-is-the-good-one'>The Stream tab is the good one</a></li> +<li>⇢ <a href='#filtering-more-thoroughly'>Filtering, more thoroughly</a></li> +<li>⇢ <a href='#recording'>Recording</a></li> +<li>⇢ <a href='#querying-a-parquet-trace-with-clickhouse'>Querying a parquet trace with ClickHouse</a></li> +<li>⇢ <a href='#reproducing-the-whole-demo'>Reproducing the whole demo</a></li> +<li>⇢ <a href='#what-s-still-missing'>What's still missing</a></li> +</ul><br /> +<h2 style='display: inline' id='what-it-does'>What it does</h2><br /> +<br /> +<span>ior attaches BPF tracepoints to a chunk of the synchronous-I/O syscall surface — open, read, write, stat, mmap, sync, link, fcntl, dup, the obvious ones. Each enter/exit pair becomes an event with a duration plus an inter-syscall gap, and the events feed a Bubble Tea dashboard with seven tabs: a live flamegraph, an overview, sortable per-syscall / per-file / per-process tables, latency histograms, and a live event stream with a stackable filter UI on top.</span><br /> +<br /> +<span>Same shape as the old I/O Riot in spirit: capture what the system is actually doing, not synthetic load. Different shape in execution: no replay engine, no separate record file unless you ask for one, no kernel-debug-info dance.</span><br /> +<br /> +<h2 style='display: inline' id='a-short-detour-ebpf-and-libbpfgo'>A short detour: eBPF and libbpfgo</h2><br /> +<br /> +<span>If you haven't touched eBPF before: it's a small in-kernel bytecode VM. You compile a tiny C program, the kernel verifies it can't crash or loop forever, and then it runs every time some hook fires — a syscall enter/exit, a kprobe, a tracepoint, a network packet. The program writes events into a ring buffer that userspace mmaps and drains. No kernel module, no patched kernel, no debug symbols required.</span><br /> +<br /> +<span>ior plugs into the syscall tracepoints — <span class='inlinecode'>sys_enter_openat</span>, <span class='inlinecode'>sys_exit_read</span>, etc. — and the BPF side does the bare minimum: timestamp the event, copy a few fields, push to a perf ring buffer. All the heavy lifting (string interning, latency math, aggregation, the dashboard) is in Go on the userspace side.</span><br /> +<br /> +<span>The kernel ships a C library called libbpf that handles loading the program, attaching it to hooks, managing maps, and reading the ring buffer. There are two well-known ways to drive that from Go:</span><br /> +<br /> +<ul> +<li>libbpfgo (Aqua Security): a thin cgo wrapper around libbpf. You ship libbpf along with your binary and call into the same C API that <span class='inlinecode'>bpftool</span> and <span class='inlinecode'>perf</span> use.</li> +<li>cilium/ebpf: a from-scratch pure-Go reimplementation of everything libbpf does — ELF parser, BTF resolver, syscall layer, the lot.</li> +</ul><br /> +<span>I went with libbpfgo specifically because it's a wrapper, not a reimplementation. Whatever lands in libbpf upstream — new map types, new attach kinds, CO-RE fixes — I get for free the next kernel cycle. The pure-Go variant has to chase libbpf's feature set in parallel, and any divergence is on me to debug. For a tracer that's mostly value-add on the userspace side, "be a thin client of the kernel's own library" wins.</span><br /> +<br /> +<span>The cost is cgo. Every call from Go into libbpf crosses the cgo boundary, which historically meant tens to ~hundred-ish nanoseconds of overhead per call — register save/restore, a stack switch onto g0, goroutine state bookkeeping. Cheap in absolute terms, but it adds up if you call into C inside a tight loop. ior keeps the actual hot path on the kernel side and only crosses into Go once per drained batch of events from the ring buffer, so the per-call cost is amortized over thousands of events. In practice it doesn't show up in profiles.</span><br /> +<br /> +<span>Go 1.26, the current release at the time of writing (late April 2026), is the one that finally took a serious bite out of cgo's per-call cost — the runtime can elide a chunk of the bookkeeping for calls that don't need it. Real-world wins depend heavily on the workload, but the rough direction is that cgo now feels closer to "an unusually expensive function call" than to "a context switch", which is the right mental model for almost everyone touching a C library from Go. The shorter version: cgo overhead used to be a real footgun for ports that called into C in the inner loop. With Go 1.26 it's a footnote unless you're doing many millions of small calls per second, in which case batching across the boundary still fixes it.</span><br /> +<br /> +<h2 style='display: inline' id='the-whole-thing-as-a-tape-pipeline'>The whole thing as a tape pipeline</h2><br /> +<br /> +<span>The demo isn't a screencast I sat through. It's 14 VHS tapes that drive the TUI deterministically, with a background workload generator producing real syscall traffic for the trace to chew on. One <span class='inlinecode'>mage demo</span> and every GIF below regenerates from scratch. The boring part of "make a demo" — having to re-record everything when the UI shifts — goes away.</span><br /> +<br /> +<h2 style='display: inline' id='first-launch'>First launch</h2><br /> +<br /> +<!-- Generator: GNU source-highlight 3.1.9 +by Lorenzo Bettini +http://www.lorenzobettini.it +http://www.gnu.org/software/src-highlite --> +<pre>sudo ./ior +</pre> +<br /> +<span>You land on the PID picker. The default selection is "All PIDs", so Enter just dumps you straight at the dashboard.</span><br /> +<br /> +<a href='./ior-guided-tour/01-launch.gif'><img alt='Cold start: PID picker, then the dashboard' title='Cold start: PID picker, then the dashboard' src='./ior-guided-tour/01-launch.gif' /></a><br /> +<br /> +<span>The dashboard opens on the **live flamegraph**. Bars grow as new events arrive. The whole thing is keyboard-driven: <span class='inlinecode'>h</span>/<span class='inlinecode'>l</span> walk siblings at the current depth, <span class='inlinecode'>j</span>/<span class='inlinecode'>k</span> step deeper or shallower, <span class='inlinecode'>enter</span> zooms into the selected subtree (the rest of the chart greys out and the selection becomes the new root), <span class='inlinecode'>u</span> or <span class='inlinecode'>Esc</span> undoes the zoom. <span class='inlinecode'>o</span> cycles the stack ordering — <span class='inlinecode'>comm/path/tracepoint</span>, <span class='inlinecode'>path/tracepoint/comm</span>, etc. — and <span class='inlinecode'>b</span> toggles the metric driving bar width between event count and total bytes.</span><br /> +<br /> +<a href='./ior-guided-tour/13-tui-flamegraph.gif'><img alt='Live in-TUI flamegraph: navigate, zoom, undo, cycle order + metric' title='Live in-TUI flamegraph: navigate, zoom, undo, cycle order + metric' src='./ior-guided-tour/13-tui-flamegraph.gif' /></a><br /> +<br /> +<h2 style='display: inline' id='the-seven-tabs-in-30-seconds-each'>The seven tabs, in 30 seconds each</h2><br /> +<br /> +<span>The number keys jump between tabs. <span class='inlinecode'>tab</span> and <span class='inlinecode'>shift+tab</span> step.</span><br /> +<br /> +<span><span class='inlinecode'>2</span> is **Overview** — a sparkline plus the top syscalls and top paths, the at-a-glance view.</span><br /> +<br /> +<a href='./ior-guided-tour/02-overview-tab.gif'><img alt='Overview tab' title='Overview tab' src='./ior-guided-tour/02-overview-tab.gif' /></a><br /> +<br /> +<span><span class='inlinecode'>3</span> is **Syscalls** — a sortable table. <span class='inlinecode'>s</span> sorts by the selected column, <span class='inlinecode'>S</span> reverses.</span><br /> +<br /> +<a href='./ior-guided-tour/03-syscalls-tab.gif'><img alt='Syscalls table with sort + reverse-sort' title='Syscalls table with sort + reverse-sort' src='./ior-guided-tour/03-syscalls-tab.gif' /></a><br /> +<br /> +<span><span class='inlinecode'>4</span> is **Files**. The interesting key here is <span class='inlinecode'>d</span>: it rolls per-file rows up into their parent directory. Essential when you've got a process touching ten thousand files in <span class='inlinecode'>/usr/share/</span>.</span><br /> +<br /> +<a href='./ior-guided-tour/04-files-tab.gif'><img alt='Directory grouping toggle' title='Directory grouping toggle' src='./ior-guided-tour/04-files-tab.gif' /></a><br /> +<br /> +<span><span class='inlinecode'>5</span> is **Processes** — same idea, per-process / per-comm.</span><br /> +<br /> +<a href='./ior-guided-tour/05-processes-tab.gif'><img alt='Processes tab' title='Processes tab' src='./ior-guided-tour/05-processes-tab.gif' /></a><br /> +<br /> +<span><span class='inlinecode'>6</span> is **Latency + Gaps**. Two histograms: how long each syscall took, and the idle-on-the-same-thread gap between syscalls. The dd loop in the demo workload spreads the latency distribution out so you can actually see it.</span><br /> +<br /> +<a href='./ior-guided-tour/06-latency-gaps-tab.gif'><img alt='Latency + gap histograms' title='Latency + gap histograms' src='./ior-guided-tour/06-latency-gaps-tab.gif' /></a><br /> +<br /> +<span><span class='inlinecode'>7</span> is **Stream** — the live tail. This is where you spend most of your time when something's actually broken.</span><br /> +<br /> +<a href='./ior-guided-tour/07-stream-live.gif'><img alt='Stream tab live-tailing' title='Stream tab live-tailing' src='./ior-guided-tour/07-stream-live.gif' /></a><br /> +<br /> +<h2 style='display: inline' id='the-stream-tab-is-the-good-one'>The Stream tab is the good one</h2><br /> +<br /> +<span><span class='inlinecode'>space</span> pauses. In pause mode, <span class='inlinecode'>j</span>/<span class='inlinecode'>k</span> and arrow keys move the row/column cursor. Hitting <span class='inlinecode'>Enter</span> on a cell pushes a new filter onto a stack, narrowing what you see. Pile them up — comm, then syscall, then file — and <span class='inlinecode'>Esc</span> pops them off LIFO when you want to back out.</span><br /> +<br /> +<a href='./ior-guided-tour/08-stream-pause-filter.gif'><img alt='Pause, push two filters, undo with Esc' title='Pause, push two filters, undo with Esc' src='./ior-guided-tour/08-stream-pause-filter.gif' /></a><br /> +<br /> +<span><span class='inlinecode'>/</span> and <span class='inlinecode'>?</span> are regex search forward/backward. <span class='inlinecode'>n</span> and <span class='inlinecode'>N</span> walk matches. The search runs against every column in the ring buffer and wraps at the end. Search and filtering are different beasts: search highlights and jumps, filtering hides everything that doesn't match.</span><br /> +<br /> +<a href='./ior-guided-tour/09-stream-regex-search.gif'><img alt='Regex search' title='Regex search' src='./ior-guided-tour/09-stream-regex-search.gif' /></a><br /> +<br /> +<span><span class='inlinecode'>e</span> exports the current filtered snapshot to a CSV in the working directory. <span class='inlinecode'>x</span> does the same for the paused stream view specifically (preserving your filter stack), <span class='inlinecode'>X</span> prompts for a filename, <span class='inlinecode'>E</span> opens the most recent export in <span class='inlinecode'>$EDITOR</span>.</span><br /> +<br /> +<a href='./ior-guided-tour/10-stream-csv-export.gif'><img alt='CSV export' title='CSV export' src='./ior-guided-tour/10-stream-csv-export.gif' /></a><br /> +<br /> +<h2 style='display: inline' id='filtering-more-thoroughly'>Filtering, more thoroughly</h2><br /> +<br /> +<span>The Enter-to-push trick isn't unique to Stream. It works the same on Files, Syscalls, and Processes: highlight a row, hit Enter, and the cell value becomes a filter against the entire dashboard. Three tabs of "I see one weird path / comm / syscall, drill in" with one keystroke.</span><br /> +<br /> +<span>The filter status line gives you a one-glance summary of every active frame, written like:</span><br /> +<br /> +<ul> +<li><span class='inlinecode'>comm~bash</span> — substring match on a string column. This is what Enter-on-a-cell produces for <span class='inlinecode'>comm</span>, <span class='inlinecode'>syscall</span>, and <span class='inlinecode'>file</span>.</li> +<li><span class='inlinecode'>pid=1234</span> — exact equality. Used for <span class='inlinecode'>pid</span>, <span class='inlinecode'>tid</span>, <span class='inlinecode'>fd</span>, <span class='inlinecode'>ret</span>, <span class='inlinecode'>bytes</span>.</li> +<li><span class='inlinecode'>latency>=5ms</span> / <span class='inlinecode'>gap>=10us</span> — numeric comparison with a duration suffix. The full operator set is <span class='inlinecode'>></span>, <span class='inlinecode'><</span>, <span class='inlinecode'>=</span>, <span class='inlinecode'>>=</span>, <span class='inlinecode'><=</span>, <span class='inlinecode'>!=</span>.</li> +</ul><br /> +<span>Stack frames AND together, so pushing <span class='inlinecode'>comm~bash</span> and then <span class='inlinecode'>syscall~openat</span> shows you bash's openat calls, not bash OR openat. <span class='inlinecode'>Esc</span> (or <span class='inlinecode'>F</span>) pops the most recent frame.</span><br /> +<br /> +<span>Two other knobs do related work:</span><br /> +<br /> +<ul> +<li><span class='inlinecode'>p</span>, <span class='inlinecode'>t</span>, <span class='inlinecode'>o</span> open the PID, TID, and probe-toggle dialogs. These are global filters: they reconfigure the BPF side, so kernel-level events for excluded PIDs/probes never even reach userspace. Cheaper than filtering a firehose, but it also means the filter applies to recordings (the parquet file only contains rows the kernel let through).</li> +<li>The CLI mirrors of those dialogs let you bake the same scoping into a one-shot run: <span class='inlinecode'>-pid</span>, <span class='inlinecode'>-tid</span>, <span class='inlinecode'>-comm</span>, <span class='inlinecode'>-path</span>, plus <span class='inlinecode'>-tps <regex></span> / <span class='inlinecode'>-tpsExclude <regex></span> for picking which tracepoints to attach in the first place.</li> +</ul><br /> +<a href='./ior-guided-tour/11-pid-tid-probe.gif'><img alt='PID, TID, and probe pickers' title='PID, TID, and probe pickers' src='./ior-guided-tour/11-pid-tid-probe.gif' /></a><br /> +<br /> +<h2 style='display: inline' id='recording'>Recording</h2><br /> +<br /> +<span>Three persistence flows, each for a different job:</span><br /> +<br /> +<ul> +<li><span class='inlinecode'>R</span> from the dashboard starts streaming **Parquet** — every event row that survives your current TUI filter goes to disk continuously. <span class='inlinecode'>R</span> again stops. Footer shows the active file or the last error.</li> +</ul><br /> +<a href='./ior-guided-tour/12-parquet-recording.gif'><img alt='Parquet recording from the TUI' title='Parquet recording from the TUI' src='./ior-guided-tour/12-parquet-recording.gif' /></a><br /> +<br /> +<ul> +<li><span class='inlinecode'>sudo ./ior -flamegraph -name <n></span> writes one aggregated <span class='inlinecode'>.ior.zst</span> artifact at shutdown. Aggregated counters, not per-event rows. Cheaper to write, ideal for ior's native flamegraph workflow and integration tests.</li> +</ul><br /> +<ul> +<li><span class='inlinecode'>sudo ./ior -parquet trace.parquet</span> is the headless firehose — every row, no TUI, no filtering. <span class='inlinecode'>sudo ./ior -plain</span> is even lighter: CSV to stdout, pipe it into anything.</li> +</ul><br /> +<a href='./ior-guided-tour/14-headless-modes.gif'><img alt='All three headless flows in one tape' title='All three headless flows in one tape' src='./ior-guided-tour/14-headless-modes.gif' /></a><br /> +<br /> +<h2 style='display: inline' id='querying-a-parquet-trace-with-clickhouse'>Querying a parquet trace with ClickHouse</h2><br /> +<br /> +<span>The schema is flat and stable: <span class='inlinecode'>seq, time_ns, gap_ns, latency_ns, comm, pid, tid, syscall, fd, ret, bytes, file, is_error, filter_epoch</span>. ClickHouse Local reads parquet directly without a server, which makes it a perfect post-mortem tool — point it at the file and run SQL:</span><br /> +<br /> +<!-- Generator: GNU source-highlight 3.1.9 +by Lorenzo Bettini +http://www.lorenzobettini.it +http://www.gnu.org/software/src-highlite --> +<pre>clickhouse <b><u><font color="#000000">local</font></u></b> --query <font color="#808080">"</font> +<font color="#808080"> SELECT comm, syscall, count() AS n, formatReadableSize(sum(bytes)) AS total</font> +<font color="#808080"> FROM file('trace.parquet', Parquet)</font> +<font color="#808080"> GROUP BY comm, syscall</font> +<font color="#808080"> ORDER BY n DESC</font> +<font color="#808080"> LIMIT 10</font> +<font color="#808080">"</font> +</pre> +<br /> +<pre> +bash read 18432 72.10 MiB +dd write 14209 1.39 GiB +fish openat 9871 0.00 B +systemd-journ… write 4112 1.62 MiB +... +</pre> +<br /> +<span>The fields you actually want for performance work are <span class='inlinecode'>latency_ns</span> and <span class='inlinecode'>gap_ns</span>. P99 by syscall, only the ones that landed in error:</span><br /> +<br /> +<!-- Generator: GNU source-highlight 3.1.9 +by Lorenzo Bettini +http://www.lorenzobettini.it +http://www.gnu.org/software/src-highlite --> +<pre>clickhouse <b><u><font color="#000000">local</font></u></b> --query <font color="#808080">"</font> +<font color="#808080"> SELECT</font> +<font color="#808080"> syscall,</font> +<font color="#808080"> count() AS n,</font> +<font color="#808080"> quantile(0.5)(latency_ns)/1000 AS p50_us,</font> +<font color="#808080"> quantile(0.99)(latency_ns)/1000 AS p99_us</font> +<font color="#808080"> FROM file('trace.parquet', Parquet)</font> +<font color="#808080"> WHERE is_error = 1</font> +<font color="#808080"> GROUP BY syscall</font> +<font color="#808080"> ORDER BY p99_us DESC</font> +<font color="#808080">"</font> +</pre> +<br /> +<span>Same trick works in DuckDB (<span class='inlinecode'>duckdb -c "SELECT ... FROM 'trace.parquet'"</span>), pandas, polars, anything that reads Parquet. The point of streaming Parquet rather than ior's native <span class='inlinecode'>.ior.zst</span> format is exactly this: once it's on disk, you're in the standard data-tools ecosystem.</span><br /> +<br /> +<h2 style='display: inline' id='reproducing-the-whole-demo'>Reproducing the whole demo</h2><br /> +<br /> +<!-- Generator: GNU source-highlight 3.1.9 +by Lorenzo Bettini +http://www.lorenzobettini.it +http://www.gnu.org/software/src-highlite --> +<pre>mage installDemoTools <i><font color="silver"># one-time: VHS via go install + ttyd from dnf</font></i> +sudo -v <i><font color="silver"># warm the sudo timestamp once</font></i> +mage demo <i><font color="silver"># ~10 minutes, fully headless, safe to background</font></i> +</pre> +<br /> +<span>To rebuild a single GIF after editing its tape: <span class='inlinecode'>TAPE=07-stream-live mage demoOne</span>.</span><br /> +<br /> +<h2 style='display: inline' id='what-s-still-missing'>What's still missing</h2><br /> +<br /> +<span>ior is pre-alpha and basically a personal tool. The headline gaps:</span><br /> +<br /> +<ul> +<li>No record/replay — that was the whole point of the original I/O Riot. The new one is a tracer, not a workload simulator. I keep going back and forth on whether to put replay back in.</li> +<li>No userspace symbol resolution. Stacks are at the syscall surface, not "which line of which library called read".</li> +<li>No remote / cluster mode. Single host, one trace at a time.</li> +</ul><br /> +<span>But the live flamegraph, the stackable stream filters, and the cheap parquet capture together cover the cases I actually hit week to week. The demo above is the easiest way to get a feel for whether it's the kind of tool you want.</span><br /> +<br /> +<a class='textlink' href='https://codeberg.org/snonux/ior'>Source on Codeberg</a><br /> +<a class='textlink' href='https://codeberg.org/snonux/ior/src/branch/main/demo/TUTORIAL.md'>The full in-repo tutorial</a><br /> +<p class="footer"> + Generated with <a href="https://codeberg.org/snonux/gemtexter">Gemtexter 3.0.1-develop</a> | + served by <a href="https://www.OpenBSD.org">OpenBSD</a>/<a href="https://man.openbsd.org/relayd.8">relayd(8)</a>+<a href="https://man.openbsd.org/httpd.8">httpd(8)</a> | + <a href="https://foo.zone/site-mirrors.html">Site Mirrors</a> + <br /> + Webring: <a href="https://shring.sh/foo.zone/previous">previous</a> | <a href="https://shring.sh">shring</a> | <a href="https://shring.sh/foo.zone/next">next</a> +</p> +</body> +</html> diff --git a/gemfeed/DRAFT-unveiling-ior-ng.html b/gemfeed/DRAFT-unveiling-ior-ng.html new file mode 100644 index 00000000..677594c0 --- /dev/null +++ b/gemfeed/DRAFT-unveiling-ior-ng.html @@ -0,0 +1,386 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<title>Unveiling I/O Riot NG</title> +<link rel="shortcut icon" type="image/gif" href="/favicon.ico" /> +<link rel="stylesheet" href="../style.css" /> +<link rel="stylesheet" href="style-override.css" /> +</head> +<body> +<p class="header"> +<a href="https://foo.zone">Home</a> | <a href="https://codeberg.org/snonux/foo.zone/src/branch/content-md/gemfeed/DRAFT-unveiling-ior-ng.md">Markdown</a> | <a href="gemini://foo.zone/gemfeed/DRAFT-unveiling-ior-ng.gmi">Gemini</a> | <a href="https://snonux.foo">Microblog</a> | <a href="https://irregular.ninja">Street photography</a> +</p> +<h1 style='display: inline' id='unveiling-io-riot-ng'>Unveiling I/O Riot NG</h1><br /> +<br /> +<span class='quote'>Draft — not in the gemfeed yet. Promote with the usual rename + index dance.</span><br /> +<br /> +<span>I rewrote I/O Riot. The old one was C + Systemtap and dates from 2017. The new one — call it ior — is Go + C + BPF via libbpfgo, runs on Linux, and is mostly a TUI dashboard rather than a record/replay box. Since pictures are worth more than yet another README table of key bindings, I built a demo.</span><br /> +<br /> +<a href='./unveiling-ior-ng/00-hero-flamegraph.png'><img alt='ior's live flamegraph: every running process, by file path, by syscall — width = event volume' title='ior's live flamegraph: every running process, by file path, by syscall — width = event volume' src='./unveiling-ior-ng/00-hero-flamegraph.png' /></a><br /> +<br /> +<a class='textlink' href='https://codeberg.org/snonux/ior'>I/O Riot NG on Codeberg</a><br /> +<a class='textlink' href='./2018-06-01-realistic-load-testing-with-ioriot-for-linux.html'>the original I/O Riot post (2018)</a><br /> +<br /> +<h2 style='display: inline' id='table-of-contents'>Table of Contents</h2><br /> +<br /> +<ul> +<li><a href='#unveiling-io-riot-ng'>Unveiling I/O Riot NG</a></li> +<li>⇢ <a href='#what-it-does'>What it does</a></li> +<li>⇢ <a href='#a-short-detour-ebpf-and-libbpfgo'>A short detour: eBPF and libbpfgo</a></li> +<li>⇢ ⇢ <a href='#co-re--the-part-that-makes-ior-actually-portable'>CO-RE — the part that makes ior actually portable</a></li> +<li>⇢ ⇢ <a href='#if-you-want-to-go-deeper'>If you want to go deeper</a></li> +<li>⇢ <a href='#the-whole-thing-as-a-tape-pipeline'>The whole thing as a tape pipeline</a></li> +<li>⇢ <a href='#first-launch'>First launch</a></li> +<li>⇢ <a href='#the-seven-tabs-in-30-seconds-each'>The seven tabs, in 30 seconds each</a></li> +<li>⇢ ⇢ <a href='#2-overview'><span class='inlinecode'>2</span> Overview</a></li> +<li>⇢ ⇢ <a href='#3-syscalls'><span class='inlinecode'>3</span> Syscalls</a></li> +<li>⇢ ⇢ <a href='#4-files'><span class='inlinecode'>4</span> Files</a></li> +<li>⇢ ⇢ <a href='#5-processes'><span class='inlinecode'>5</span> Processes</a></li> +<li>⇢ ⇢ <a href='#6-latency--gaps'><span class='inlinecode'>6</span> Latency + Gaps</a></li> +<li>⇢ ⇢ <a href='#7-stream'><span class='inlinecode'>7</span> Stream</a></li> +<li>⇢ <a href='#the-stream-tab-is-the-good-one'>The Stream tab is the good one</a></li> +<li>⇢ <a href='#filtering-more-thoroughly'>Filtering, more thoroughly</a></li> +<li>⇢ <a href='#recording'>Recording</a></li> +<li>⇢ <a href='#querying-a-parquet-trace-with-clickhouse'>Querying a parquet trace with ClickHouse</a></li> +<li>⇢ <a href='#reproducing-the-whole-demo'>Reproducing the whole demo</a></li> +<li>⇢ <a href='#what-s-still-missing'>What's still missing</a></li> +</ul><br /> +<h2 style='display: inline' id='what-it-does'>What it does</h2><br /> +<br /> +<span>ior attaches BPF tracepoints to a chunk of the synchronous-I/O syscall surface — open, read, write, stat, mmap, sync, link, fcntl, dup, the obvious ones. Each enter/exit pair becomes an event with a duration plus an inter-syscall gap, and the events feed a Bubble Tea dashboard with seven tabs: a live flamegraph, an overview, sortable per-syscall / per-file / per-process tables, latency histograms, and a live event stream with a stackable filter UI on top.</span><br /> +<br /> +<span>Same shape as the old I/O Riot in spirit: capture what the system is actually doing, not synthetic load. Different shape in execution: no replay engine, no separate record file unless you ask for one, no kernel-debug-info dance.</span><br /> +<br /> +<a href='./unveiling-ior-ng/00-logo.png'><img alt='I/O Riot NG logo' title='I/O Riot NG logo' src='./unveiling-ior-ng/00-logo.png' /></a><br /> +<br /> +<h2 style='display: inline' id='a-short-detour-ebpf-and-libbpfgo'>A short detour: eBPF and libbpfgo</h2><br /> +<br /> +<span>If you haven't touched eBPF before: it's a small in-kernel bytecode VM. You compile a tiny C program, the kernel verifies it can't crash or loop forever, and then it runs every time some hook fires — a syscall enter/exit, a kprobe, a tracepoint, a network packet. The program writes events into a ring buffer that userspace mmaps and drains. No kernel module, no patched kernel, no debug symbols required.</span><br /> +<br /> +<span>ior plugs into the syscall tracepoints — <span class='inlinecode'>sys_enter_openat</span>, <span class='inlinecode'>sys_exit_read</span>, etc. — and the BPF side does the bare minimum: timestamp the event, copy a few fields, push to a perf ring buffer. All the heavy lifting (string interning, latency math, aggregation, the dashboard) is in Go on the userspace side.</span><br /> +<br /> +<span>The kernel ships a C library called libbpf that handles loading the program, attaching it to hooks, managing maps, and reading the ring buffer. There are two well-known ways to drive that from Go:</span><br /> +<br /> +<ul> +<li>libbpfgo (Aqua Security): a thin cgo wrapper around libbpf. You ship libbpf along with your binary and call into the same C API that <span class='inlinecode'>bpftool</span> and <span class='inlinecode'>perf</span> use.</li> +<li>cilium/ebpf: a from-scratch pure-Go reimplementation of everything libbpf does — ELF parser, BTF resolver, syscall layer, the lot.</li> +</ul><br /> +<span>I went with libbpfgo specifically because it's a wrapper, not a reimplementation. Whatever lands in libbpf upstream — new map types, new attach kinds, CO-RE fixes — I get for free the next kernel cycle. The pure-Go variant has to chase libbpf's feature set in parallel, and any divergence is on me to debug. For a tracer that's mostly value-add on the userspace side, "be a thin client of the kernel's own library" wins.</span><br /> +<br /> +<h3 style='display: inline' id='co-re--the-part-that-makes-ior-actually-portable'>CO-RE — the part that makes ior actually portable</h3><br /> +<br /> +<span>The old I/O Riot was Systemtap. Systemtap programs are translated into a kernel module against the running kernel's exact headers, and that module then has to be loaded with <span class='inlinecode'>insmod</span>. That meant: the user has to install a kernel-debuginfo package matching their running kernel, and a fresh build per host (or per kernel update). On the BSD-style "you only run what you compiled here" laptop crowd that was tolerable; on a fleet of distros + kernel versions it was a recurring tax. Half of the original I/O Riot's README was about kernel-debuginfo dance steps.</span><br /> +<br /> +<span>CO-RE — Compile Once, Run Everywhere — is the eBPF feature that throws all of that out. The idea, in one paragraph: when you write a BPF program that reads <span class='inlinecode'>task->mm->start_stack</span>, you don't bake the offsets of those fields into the compiled program. Instead, the compiler emits relocation records ("at this instruction, fetch the offset of <span class='inlinecode'>mm</span> inside <span class='inlinecode'>task_struct</span>"). At load time, libbpf looks up the actual offsets in the target kernel's BTF (BPF Type Format — a description of every kernel struct, embedded in <span class='inlinecode'>/sys/kernel/btf/vmlinux</span> on any modern kernel) and patches the program in place. The same <span class='inlinecode'>.bpf.o</span> that ran on a 5.10 Debian kernel runs on a 6.8 Fedora kernel without recompilation.</span><br /> +<br /> +<span>Pictorially, the contrast looks like this:</span><br /> +<br /> +<pre> +Old I/O Riot (Systemtap) New ior (libbpf + CO-RE) +───────────────────────── ──────────────────────────── + .stp source .bpf.c source + │ │ + │ needs THIS kernel's headers │ build ONCE against vmlinux.h + │ + debuginfo package installed │ (generated from any kernel BTF) + ▼ ▼ + per-host translate + compile one portable .bpf.o + │ │ + ▼ ▼ + per-host kernel module same binary on every host + │ │ + insmod / modprobe libbpf loader: + │ │ • read /sys/kernel/btf/vmlinux + ▼ │ • patch field offsets + attached, this kernel only │ • verify + load + ▼ + attached, runs anywhere +</pre> +<br /> +<span>What that buys ior in practice: I ship a single <span class='inlinecode'>ior</span> binary. On any Linux ≥4.18-ish with BTF available (which is almost all of them now — Debian, Ubuntu, Fedora, Arch, RHEL all ship <span class='inlinecode'>CONFIG_DEBUG_INFO_BTF=y</span> by default), it just works. No kernel-debuginfo dependency, no per-kernel build matrix, no DKMS hooks. The first time I tried <span class='inlinecode'>scp ior fedora-box:</span> and it ran without complaint after a 6-month gap I had to double-check it wasn't silently doing nothing.</span><br /> +<br /> +<span>The runtime shape of a trace pipeline lines up with that:</span><br /> +<br /> +<pre> + kernel side userspace (this binary) + ─────────── ─────────────────────── + ┌──────────────────────┐ + tracepoint: │ Go process │ + sys_enter_openat │ ┌────────────────┐ │ + │ │ │ aggregator │ │ + ▼ │ │ (latency, │ │ + ┌─────────┐ │ │ stacks, │ │ + │ BPF prog│ ─── perf ring buf ──────────>│──│ filters) │ │ + │ (verified │ └─────┬──────────┘ │ + │ bytecode) │ │ │ + └─────────┘ │ ▼ │ + │ Bubble Tea TUI / │ + │ parquet writer / │ + │ CSV stdout │ + └──────────────────────┘ +</pre> +<br /> +<span>The cost is cgo. Every call from Go into libbpf crosses the cgo boundary, which historically meant tens to ~hundred-ish nanoseconds of overhead per call — register save/restore, a stack switch onto g0, goroutine state bookkeeping. Cheap in absolute terms, but it adds up if you call into C inside a tight loop. ior keeps the actual hot path on the kernel side and only crosses into Go once per drained batch of events from the ring buffer, so the per-call cost is amortized over thousands of events. In practice it doesn't show up in profiles.</span><br /> +<br /> +<span>Go 1.26, the current release at the time of writing (late April 2026), is the one that finally took a serious bite out of cgo's per-call cost — the runtime can elide a chunk of the bookkeeping for calls that don't need it. Real-world wins depend heavily on the workload, but the rough direction is that cgo now feels closer to "an unusually expensive function call" than to "a context switch", which is the right mental model for almost everyone touching a C library from Go. The shorter version: cgo overhead used to be a real footgun for ports that called into C in the inner loop. With Go 1.26 it's a footnote unless you're doing many millions of small calls per second, in which case batching across the boundary still fixes it.</span><br /> +<br /> +<h3 style='display: inline' id='if-you-want-to-go-deeper'>If you want to go deeper</h3><br /> +<br /> +<span>If any of this sounds interesting and you want to learn how to write your own BPF programs, two books are the standard recommendations and both well worth the time:</span><br /> +<br /> +<ul> +<li>"Learning eBPF" by Liz Rice (O'Reilly, 2023) is the friendlier on-ramp. It walks through writing your first programs end-to-end, covers CO-RE and BTF in plain English, and is the book I'd hand to someone who has never touched the kernel side before. Liz also gave the canonical "what is eBPF" conference talk floating around YouTube, which makes a good 40-minute companion.</li> +<li>"BPF Performance Tools: Linux System and Application Observability" by Brendan Gregg (Addison-Wesley, 2019) is the encyclopedia. It's where you go after you've understood the basics and now want a complete reference for tracing every subsystem in the kernel — file systems, networking, scheduler, languages, applications — with worked tools for each. The flame-graph-driven analysis style throughout is also exactly how ior's own flamegraph tab thinks about a workload.</li> +</ul><br /> +<span>Between the two, Rice teaches you the moving parts and Gregg teaches you what to do with them.</span><br /> +<br /> +<h2 style='display: inline' id='the-whole-thing-as-a-tape-pipeline'>The whole thing as a tape pipeline</h2><br /> +<br /> +<span>The demo isn't a screencast I sat through. It's 14 VHS tapes that drive the TUI deterministically, with a background workload generator producing real syscall traffic for the trace to chew on. One <span class='inlinecode' |
