Files
nfs/docs/_results/2026-09-22-readdir-page.md
T

28 lines
1.1 KiB
Markdown
Raw Normal View History

# Measurement: the paginated READDIR
- Date: 2026-09-22
- Machine: AMD Ryzen AI Max+ Pro 395 (32 threads), otherwise idle
- Toolchain: go1.27.1, no build flags
- Command: `go test ./internal/nfsfs/ -run '^$' -bench=ReadDirPage -benchmem -count=1 -benchtime=50x`
## Baseline
The commit 340783e, measured in the same session as the new code. The
benchmark pages a 10 000 entry directory 64 entries at a time, which is the
shape of a client listing a large directory through READDIR pages: the
baseline re listed and re sorted the whole directory for every page.
## Result
Median free, 50 iterations per side, one session.
| Benchmark | Baseline | With the listing cache | Change |
|---|---|---|---|
| `BenchmarkReadDirPage64` | 1863611 ns/op, 1402 KiB/op, 20290 allocs/op | 62506 ns/op, 40 KiB/op, 267 allocs/op | -96.6 % |
A page of 64 costs 30 times less once the sorted order is cached and
revalidated against the directory's modification time, and the cost no
longer grows with the size of the directory: the numbers above are the
boundary case, where a page paid for listing and sorting ten thousand names
to serve sixty four of them.