Skip to content

Record DiskGraph read intent before the page cache

Run a temporal graph workload on a Linux CPU. Save the file reads DiskGraph asks for, compare them with actual NVMe traffic, and replay the same requests on a second kernel using generated files. A GPU and model weights are unnecessary.

DiskGraph read intent and submitted I/O sizes

RelBench Stack is a public Stack Exchange Q&A benchmark. In one pass of 512 held-out user queries, 7 bytes was the most frequent planner range and 4 KiB was the most frequent submitted read.

Rank sizes by count or bytes within each layer. The bars show shares of that layer's total. See the intent and eBPF capture commands and the read amplification they measured.

The benchmark's user-engagement task asks whether a user will post, comment, or vote in the next two years. The CPU run uses each user's timestamp to sample earlier graph neighbors and fetch their features. The cold and warm passes recorded identical size counts at both layers. RelBench Stack dataset and task

The browser reads the receipt locally. Choose a captured pass to see both layers.

What each observer sees

Graph planner

DiskGraph records the encoded header and record ranges it plans to read. These ranges describe graph work before page expansion and reuse. They include adjacency and headers as well as feature records.

Buffered file requests

A second hook records the offset and length of each READ and READV queued for the kernel. It retains the worker lane and submission group. This is the stream replay uses.

NVMe commands

The optional ebpf-syscall observer records device commands and their completions. The analysis joins completed reads to the immutable edge-file extents on the same monotonic clock. Warm file reads can complete with zero SSD reads.

The DGraphFin showcase pairs feature consumption with device traffic and replays the device commands. DiskGraph adds an earlier capture point for rerunning access through the page cache. The two replay modes answer different questions. DGraphFin showcase

Cold and warm DiskGraph measurements

Read amplification at the Buffered and SSD layers

RelBench Stack still had 15.03× Buffered read amplification with a warm page cache. On the repeat, DiskGraph asked Linux to read 763.84 MB for 50.81 MB of planner intent. The first pass had loaded those pages into RAM, so Linux served the repeat from the page cache. The tracked files generated zero SSD reads, giving 0× NVMe read amplification for the same pass.

The cold pass submitted the same Buffered reads and read 258.49 MB from NVMe, giving 5.09× NVMe amplification. Both ratios use the same baseline of 50.81 MB of planner intent per pass, counting repeated ranges each time.

The planner records encoded graph headers, adjacency and feature ranges. Buffered amplification uses the lengths DiskGraph submits to Linux before end-of-file clipping. NVMe amplification uses successful device reads attributed to the tracked edge files by offset and time. Both ratios compare whole passes. The device measurement follows the same approach as DGraphFin. DGraphFin read amplification

Load an analysis receipt to compare your own capture.

The generated fixture used 512 roots in each pass and three temporal hops. All 181,610 recorded planner ranges per pass were below 4 KiB. DiskGraph's Buffered backend submitted 21,207 requests per pass, including coalesced reads up to 64 KiB. The repeat completed the same file reads from cache. Using 4.11 MB of distinct planner bytes, the cold device ratio was 3.93×.

LayerColdRepeat
Planner bytes including reuse8,867,9788,867,978
Buffered file bytes after EOF clipping195,178,082195,178,082
Attributed NVMe read commands3,1060
Attributed NVMe read bytes16,162,8160

On a second capture of the same fixture, native buffered pread and io_uring replay each completed 42,414 captured file requests and 390,356,164 bytes per pass. Both modes returned the same per-lane checksums on generated files. The replay drains each recorded submission group, preserving requests and their grouping while leaving the original overlap and timing to the live workload.

The RelBench Stack user-engagement cold pass issued 60,363 attributed edge-file NVMe reads. Counting each planner byte once gives a 42.19 MB denominator and a separate 6.13× cold ratio. The namespace carried 0.82 MB and 0.066 MB of unrelated reads in the two windows. No excluded read overlapped a tracked edge extent. Buffered and mmap returned the same feature multiset for both workloads. Replaying the real capture through either native reader completed 317,436 requests and 1,527,685,120 bytes per pass with matching checksums.

Run and replay on a Linux CPU

Use a knlp checkout that includes the DiskGraph page-cache changes. The build needs Git, a C toolchain with liburing headers, Rustup, uv and knlp's Python Kconfig dependencies. The live fixture also needs a kernel that permits io_uring. The first build compiles the pinned native package and needs several GB of free disk. The fixture uses standard Linux buffered I/O.

make defconfig-diskgraph-page-cache
make

The default runs a synthetic graph through draft Buffered DiskGraph, records both intent layers, checks sampled timestamps, writes an analysis receipt and runs a buffered pread replay. build/diskgraph/fixture-buffered/ contains intent.jsonl, live.json and analysis.json. Each new live capture uses a new output directory.

Open analysis.json in the size visualizer or inspect both histograms and the first record from each layer with jq. Histogram keys are requested lengths in bytes. Planner records store offset and length pairs in ranges. Buffered records store file alias, offset and length triples in reads.

run=build/diskgraph/fixture-buffered
jq '.passes[] | {pass, planner_range_size_histogram, io_uring_request_size_histogram}' "$run/analysis.json"
jq -nc 'first(inputs | select(.event == "demand") | .ranges[])' "$run/intent.jsonl"
jq -nc 'first(inputs | select(.event == "read_batch") | .reads[])' "$run/intent.jsonl"
make diskgraph-replay DISKGRAPH_REPLAY_MODE=uring
make diskgraph-run DISKGRAPH_DATASET=rel-stack
make diskgraph-report DISKGRAPH_DATASET=rel-stack
make diskgraph-replay DISKGRAPH_DATASET=rel-stack DISKGRAPH_REPLAY_MODE=uring

The RelBench arm fetches the public rel-stack tables and the held-out user-engagement cohort. The pinned download is about 1.04 GB. The local index and replay files need additional space. Set DISKGRAPH_SOURCE to a matching local rel-stack directory to reuse the source tables. The workload runs native sampling and feature delivery. Pinned RelBench data

Capture intent and NVMe command sizes in the same run

The DiskGraph intent hooks write planner range lengths and submitted Buffered read lengths to intent.jsonl. The ebpf-syscall tool nvme_tp_monitor writes device command lengths and completions to nvme.jsonl. Its .bytes field comes from the command at the NVMe driver's nvme_setup_cmd tracepoint, after any page-cache effects.

On a local XFS volume backed by NVMe, run the same RelBench capture with tracing privileges. Choose a fresh run directory for each capture.

make -C /path/to/ebpf-syscall nvme_tp_monitor
sudo -v
run=build/diskgraph/stack-device
make diskgraph-run DISKGRAPH_DATASET=rel-stack DISKGRAPH_RUN="$run" \
  DISKGRAPH_NVME_MONITOR=/path/to/ebpf-syscall/nvme_tp_monitor
make diskgraph-report DISKGRAPH_RUN="$run"

The harness detects the backing namespace, starts the command below before the workload, and stops it when the workload finishes. The captured run used nvme0n1.

sudo -n /path/to/ebpf-syscall/nvme_tp_monitor \
  --disk nvme0n1 --dur 300 --jsonl "$run/nvme.jsonl"

Read a raw command's starting LBA and size, then read the per-pass histogram for completed commands attributed to the graph's edge files. The histogram keys are byte lengths. The RelBench cold pass had 58,337 attributed 4 KiB NVMe read commands. The warm pass had an empty histogram.

jq -nc 'first(inputs | select(.event_type == "nvme_cmd" and .op_name == "read") |
  {slba, bytes})' "$run/nvme.jsonl"
jq '.passes[] | {pass, nvme_read_command_sizes: (.nvme |
  with_entries(select(.key | startswith("size_")) | .key |= ltrimstr("size_")))}' "$run/analysis.json"

To replay a capture from another machine, point DISKGRAPH_CAPTURE to its intent.jsonl. Replay materializes new files with the recorded sizes and deterministic filler. It checks lengths and repeat checksums without opening the source graph or rebuilding DiskGraph. The trace contains file aliases, lengths, offsets, groups and monotonic times. Those access patterns can still be confidential. Share trace files only with the necessary authorization. ebpf-syscall replay tools

Use Buffered for the reference-free read test

Draft Buffered DiskGraph sends file reads through the Linux page cache. The default released mmap route also uses the page cache, but its mapped loads do not enter filemap_read(). It is a useful control for a buffered-only kernel change. The harness adds opt-in instrumentation to draft commit acaa797a2779. Draft DiskGraph I/O implementation

On each kernel, run the same capture once with checking enabled. Confirm the request size mix, completed bytes and returned features. Then time the live workload with intent recording and the feature audit disabled. Compare the immediate repeat separately from the opening pass. Keep the filesystem, pin, cache policy, cohort, threads and queue depth fixed across boots.

make diskgraph-run DISKGRAPH_RUN=build/diskgraph/base-buffered \
  DISKGRAPH_NO_CAPTURE=1 DISKGRAPH_NO_AUDIT=1 DISKGRAPH_THREADS=8
make diskgraph-run DISKGRAPH_BACKEND=mmap \
  DISKGRAPH_RUN=build/diskgraph/base-mmap \
  DISKGRAPH_NO_CAPTURE=1 DISKGRAPH_NO_AUDIT=1 DISKGRAPH_THREADS=8

# On the candidate kernel, repeat with new run directories.
# For a shared-cache stress control, replay the same saved request stream.
make diskgraph-replay DISKGRAPH_REPLAY_MODE=pread DISKGRAPH_CLIENTS=8 \
  DISKGRAPH_REPEAT=5 DISKGRAPH_NO_DIGEST=1

Check that hot reads actually take the experimental copy path on the kernel revision you test. Report fast-path hits or fallbacks, warm wall time and CPU time, and confirm low device traffic during the measured repeat. This page establishes the workload and replay. Kernel A/B results are still open. Reference-free filemap RFC