Storage layout benchmark #14

Open
opened 2026-10-13 15:01:18 +00:00 by kayg · 3 comments
Owner

Storage layout benchmark on the perf VM (ADR 0027).

Compare zvol16K+XFS4K, zvol16K+XFS16K, zvol4K+XFS4K (and today's ext4) for many small markdown files and large attachments, on SSD and HDD, with reflink dedupe. Perf VM disks use no host cache. Result decides where text and attachments live.

Storage layout benchmark on the perf VM (ADR 0027). Compare zvol16K+XFS4K, zvol16K+XFS16K, zvol4K+XFS4K (and today's ext4) for many small markdown files and large attachments, on SSD and HDD, with reflink dedupe. Perf VM disks use no host cache. Result decides where text and attachments live.
Author
Owner

Storage layout benchmark results

Machine: perf VM, Debian 13, kernel 6.12.111, 4 vCPU, 8 GB RAM. Scripts: /root/bench/bench.py on the VM (not in a repo). Caches dropped before each phase. Format below is median / p95 over the runs (n shown). With 3 or 5 runs, p95 is basically the worst run.

Disks tested

  • HDD = sdb (ZFS zvol on HDD, no host cache): 3 partitions of ~33 GB: ext4 default, XFS 4K (reflink=1), XFS 16K (-b size=16384 -m reflink=1). The 16K XFS mounts fine on 6.12 (kernel logs "EXPERIMENTAL: Large Block Size"). Everything runs on real block devices.
  • SSD-loop = 2 x 10 GB sparse files on / (sda, NVMe-backed zvol) as loop devices with direct-io, XFS 4K and 16K. Loop-backed, less accurate: numbers include loop overhead and are only good for comparing the two XFS block sizes, not for absolute speed.

Old v0 leftovers, the loop-backed calternal-hdd-emu target and the fstab entries are gone (the dm target was already gone; I removed the fstab line and the old ext4).

Run counts: SSD-loop 5 runs everywhere. HDD: 5 runs for large files and the no-background save test; 3 runs for workload a, SQLite FULL/NORMAL and the save-under-copy test (it is slow: one HDD run of (a) takes 5 to 8 minutes, and one run of the save test under copy takes ~10 minutes on ext4). The save-under-copy test used 100 saves per run on HDD (600 on SSD-loop and for the no-copy case).

a) 50k markdown files (0.5 to 30 KB, median ~4 KB, ~295 MB total), atomic write recipe

Create = tmp write, fsync, rename, fsync dir, 32 threads, 256 shard dirs. Rewrite = 5k random files, same recipe. Cold read = 8 threads after drop_caches. Walk = scandir + stat of all 50k. Seconds.

fs n create 50k rewrite 5k cold read 50k stat walk
HDD ext4 3 283 / 298 32.5 / 34.9 14.5 / 16.0 0.6 / 0.7
HDD XFS 4K 3 419 / 436 70.4 / 77.4 24.3 / 27.9 1.5 / 2.7
HDD XFS 16K 3 440 / 459 62.2 / 64.1 32.4 / 43.0 1.5 / 1.5
SSD-loop XFS 4K 5 148 / 153 18.1 / 20.3 3.6 / 4.0 0.6 / 0.7
SSD-loop XFS 16K 5 149 / 168 19.8 / 31.9 4.4 / 4.7 0.6 / 0.6

Reading this: a fully fsynced create costs ~6 to 9 ms per file even with 32 threads, because every sync write goes to a zvol with no host cache. That is the dominant cost, not the fs. ext4 beats XFS here by ~1.5x on create and 2x on rewrite and cold read. 16K blocks give no gain for small files (a 4 KB note takes a whole 16K block, so more space and more read IO).

b) Single atomic save latency (ms), one thread, with and without a background cp of a 1 GB file looping on the same fs

Median / p95 across runs of the per-run p50, p95, p99.

fs background copy n p50 p95 p99 max
HDD ext4 no 5 41.2 / 44.7 75.6 / 95.9 148 / 588 211 / 1004
HDD ext4 yes 3 5667 / 8726 36363 / 47864 73194 / 104857 same as p99 (100 saves)
HDD XFS 4K no 5 27.9 / 29.5 51.5 / 104 83 / 649 143 / 1888
HDD XFS 4K yes 3 26.5 / 26.6 51.9 / 58.1 92.6 / 94.6 92.6 / 94.6
HDD XFS 16K no 5 25.3 / 25.4 51.1 / 318 85 / 551 201 / 1589
HDD XFS 16K yes 3 25.2 / 25.5 62.1 / 64.5 129 / 151 129 / 151
SSD-loop XFS 4K no / yes 5 23.0 / 23.1 27.3 / 28.2 37 / 34 53 / 45
SSD-loop XFS 16K no / yes 5 23.7 / 23.2 32.5 / 29.2 47 / 37 93 / 56

This is the big result. On ext4 with a large copy running, a single note save takes seconds (p50 5.7 s, worst 100 s) because fsync on ext4 has to drag the copy's dirty data through the journal. XFS stays flat (p50 ~26 ms, same as with no copy). The saves under copy on HDD ran only 100 saves per run, so the p99 there is the max.

MB/s, median / p95. Reflink and hardlink are the median of 5 copies per run.

fs n write MB/s read MB/s (cold) reflink copy extra space hardlink extra space
HDD ext4 5 72 / 76 1617 / 1663 not supported; full copy 3.6 s +315 MB per copy 5 us 0
HDD XFS 4K 5 70 / 76 773 / 903 3.1 ms 0 MB 9 us 0
HDD XFS 16K 5 73 / 74 963 / 1225 3.2 ms 0 MB 8 us 0
SSD-loop XFS 4K 5 596 / 1061 1659 / 1951 1.3 ms 0 MB 5 us 0
SSD-loop XFS 16K 5 473 / 898 1632 / 1655 1.6 ms 0 MB 6 us 0

Caveat: HDD "cold" read speeds of 800 to 1600 MB/s are not real disk speed. drop_caches clears only the guest cache; the Proxmox host ZFS ARC still holds the data. Write speed (~72 MB/s) is the honest HDD number. Sequential throughput is the same for ext4, XFS 4K and 16K. cp --reflink=always fails on ext4 as expected, so the CAS needs hardlinks there (or XFS).

d) SQLite WAL, 10k single-row transactions (commit each), tx/s median / p95

fs n synchronous=FULL FULL p99 latency ms NORMAL
HDD ext4 3 96 / 97 36 4614 / 4756
HDD XFS 4K 3 95 / 97 38 4349 / 4384
HDD XFS 16K 3 79 / 83 40 4393 / 4490
SSD-loop XFS 4K 5 115 / 116 18 16961 / 17309
SSD-loop XFS 16K 5 114 / 115 18 14222 / 16730

FULL is ~10 ms per commit on both disks (the zvol sync-write cost), so ~100 commits/s max per DB. NORMAL is 45 to 150x faster and does not fsync per commit. The fs and block size make no real difference. 16K was slightly slower on HDD FULL (79 vs 95 tx/s).

Recommendation

  1. Filesystem: XFS 4K block (mkfs.xfs -m reflink=1) for everything, text and attachments on the same fs. It is the only option that keeps a note save at ~26 ms while a big file is being copied or uploaded (ext4 stalls for seconds), and it gives real reflinks for the CAS dedupe (3 ms, 0 extra space, vs 315 MB per copy on ext4).
  2. Not 16K blocks. No measured win on any workload, slower on cold read and SQLite FULL on HDD, wastes space for 1 to 20 KB notes, and it is still flagged EXPERIMENTAL in 6.12.
  3. Text and attachments: one XFS volume is fine. If the owner later wants isolation, put attachments/.cas on a separate XFS filesystem (reflink only works inside one fs, so the CAS and the attachment files that point to it must stay together), and keep the notes plus SQLite DBs on the SSD volume. Notes on SSD cost less than a tenth of the HDD time for read/walk.
  4. SQLite: WAL with synchronous=NORMAL for the index/search DBs (can be rebuilt from the markdown files); FULL only if we ever treat the DB as source of truth. Batch writes: the per-commit cost is ~10 ms.
  5. App design: the atomic recipe costs 6 to 9 ms per file at best (HDD), so bulk import must run parallel (32 threads gave ~100 to 170 files/s on HDD) and skip the dir fsync per file by syncing each shard dir once per batch.

Caveats

  • Loop-backed SSD numbers are less accurate (loop adds a layer, and the first attempt hung the VM in writeback until I switched to direct-io loops and disabled wbt on sda). Treat them as 4K vs 16K only.
  • Everything sits on ZFS zvols on the host, so absolute fsync latency (~10 ms) reflects the zvol sync path. A real local SSD/HDD will have different fsync cost; the relative fs differences (ext4 stalls under load, XFS reflinks) should carry over.
  • Cold reads are cold only in the guest (see above).
  • HDD runs for (a), (b under copy) and (d) are n=3, not 5, for time. "p95" with n=3 or 5 is effectively the worst run.
  • The bulk workloads use 32 threads for write phases; single-threaded would be much slower on this zvol (~40 ms per file).
  • Both disks were used by one workload at a time; no multi-user mixing.
  • 16K XFS cannot be combined with ext4-style comparisons of block size alone; ext4 was also not tested at 1K/ 16K (ext4 cannot do >4K blocks on x86 anyway).

What cannot be tested from inside the VM, and the disks to add

The zvol volblocksize (default 16K on current OpenZFS) and the ZFS recordsize are set on the host, and a zvol's volblocksize cannot be changed after creation. The VM disks sda and sdb both share one value now. To compare 4K vs 16K vs 64K volblocksize, please add these disks to the perf VM (all cache=none, discard=on, iothread=1, 40 GB each is enough):

  1. hdd-vbs4k: zvol on the HDD pool, volblocksize=4k
  2. hdd-vbs16k: zvol on the HDD pool, volblocksize=16k
  3. hdd-vbs64k: zvol on the HDD pool, volblocksize=64k
  4. ssd-vbs4k: zvol on the NVMe pool, volblocksize=4k
  5. ssd-vbs16k: zvol on the NVMe pool, volblocksize=16k
  6. ssd-vbs64k: zvol on the NVMe pool, volblocksize=64k
    Also useful: tell me the pool settings that matter (sync=standard/always, compression, SLOG present or not, ashift), and one extra unmounted 40 GB disk on the NVMe pool so the SSD can be tested as a real block device without the loop layer (replaces the loop files). With those I would rerun the same scripts with XFS 4K on each.

Reproduce: /root/bench/mount.sh then python3 /root/bench/bench.py <fs> <a|b|c|d> <runs>. Raw results: /root/bench/results/*.jsonl on the VM.

## Storage layout benchmark results Machine: perf VM, Debian 13, kernel 6.12.111, 4 vCPU, 8 GB RAM. Scripts: `/root/bench/bench.py` on the VM (not in a repo). Caches dropped before each phase. Format below is **median / p95** over the runs (n shown). With 3 or 5 runs, p95 is basically the worst run. **Disks tested** - HDD = sdb (ZFS zvol on HDD, no host cache): 3 partitions of ~33 GB: ext4 default, XFS 4K (`reflink=1`), XFS 16K (`-b size=16384 -m reflink=1`). The 16K XFS mounts fine on 6.12 (kernel logs "EXPERIMENTAL: Large Block Size"). Everything runs on real block devices. - SSD-loop = 2 x 10 GB sparse files on / (sda, NVMe-backed zvol) as loop devices with direct-io, XFS 4K and 16K. **Loop-backed, less accurate**: numbers include loop overhead and are only good for comparing the two XFS block sizes, not for absolute speed. Old v0 leftovers, the loop-backed `calternal-hdd-emu` target and the fstab entries are gone (the dm target was already gone; I removed the fstab line and the old ext4). Run counts: SSD-loop 5 runs everywhere. HDD: 5 runs for large files and the no-background save test; **3 runs** for workload a, SQLite FULL/NORMAL and the save-under-copy test (it is slow: one HDD run of (a) takes 5 to 8 minutes, and one run of the save test under copy takes ~10 minutes on ext4). The save-under-copy test used 100 saves per run on HDD (600 on SSD-loop and for the no-copy case). ### a) 50k markdown files (0.5 to 30 KB, median ~4 KB, ~295 MB total), atomic write recipe Create = tmp write, fsync, rename, fsync dir, 32 threads, 256 shard dirs. Rewrite = 5k random files, same recipe. Cold read = 8 threads after drop_caches. Walk = scandir + stat of all 50k. Seconds. | fs | n | create 50k | rewrite 5k | cold read 50k | stat walk | |---|---|---|---|---|---| | HDD ext4 | 3 | 283 / 298 | 32.5 / 34.9 | 14.5 / 16.0 | 0.6 / 0.7 | | HDD XFS 4K | 3 | 419 / 436 | 70.4 / 77.4 | 24.3 / 27.9 | 1.5 / 2.7 | | HDD XFS 16K | 3 | 440 / 459 | 62.2 / 64.1 | 32.4 / 43.0 | 1.5 / 1.5 | | SSD-loop XFS 4K | 5 | 148 / 153 | 18.1 / 20.3 | 3.6 / 4.0 | 0.6 / 0.7 | | SSD-loop XFS 16K | 5 | 149 / 168 | 19.8 / 31.9 | 4.4 / 4.7 | 0.6 / 0.6 | Reading this: a fully fsynced create costs ~6 to 9 ms per file even with 32 threads, because every sync write goes to a zvol with no host cache. That is the dominant cost, not the fs. ext4 beats XFS here by ~1.5x on create and 2x on rewrite and cold read. 16K blocks give no gain for small files (a 4 KB note takes a whole 16K block, so more space and more read IO). ### b) Single atomic save latency (ms), one thread, with and without a background `cp` of a 1 GB file looping on the same fs Median / p95 across runs of the per-run p50, p95, p99. | fs | background copy | n | p50 | p95 | p99 | max | |---|---|---|---|---|---|---| | HDD ext4 | no | 5 | 41.2 / 44.7 | 75.6 / 95.9 | 148 / 588 | 211 / 1004 | | HDD ext4 | **yes** | 3 | **5667 / 8726** | **36363 / 47864** | **73194 / 104857** | same as p99 (100 saves) | | HDD XFS 4K | no | 5 | 27.9 / 29.5 | 51.5 / 104 | 83 / 649 | 143 / 1888 | | HDD XFS 4K | yes | 3 | 26.5 / 26.6 | 51.9 / 58.1 | 92.6 / 94.6 | 92.6 / 94.6 | | HDD XFS 16K | no | 5 | 25.3 / 25.4 | 51.1 / 318 | 85 / 551 | 201 / 1589 | | HDD XFS 16K | yes | 3 | 25.2 / 25.5 | 62.1 / 64.5 | 129 / 151 | 129 / 151 | | SSD-loop XFS 4K | no / yes | 5 | 23.0 / 23.1 | 27.3 / 28.2 | 37 / 34 | 53 / 45 | | SSD-loop XFS 16K | no / yes | 5 | 23.7 / 23.2 | 32.5 / 29.2 | 47 / 37 | 93 / 56 | This is the big result. On ext4 with a large copy running, a single note save takes seconds (p50 5.7 s, worst 100 s) because fsync on ext4 has to drag the copy's dirty data through the journal. XFS stays flat (p50 ~26 ms, same as with no copy). The saves under copy on HDD ran only 100 saves per run, so the p99 there is the max. ### c) Large files, 5 x 300 MB sequential (fio, bs=1M, psync, end_fsync), plus reflink and hardlink of a 300 MB file MB/s, median / p95. Reflink and hardlink are the median of 5 copies per run. | fs | n | write MB/s | read MB/s (cold) | reflink copy | extra space | hardlink | extra space | |---|---|---|---|---|---|---|---| | HDD ext4 | 5 | 72 / 76 | 1617 / 1663 | not supported; full copy 3.6 s | +315 MB per copy | 5 us | 0 | | HDD XFS 4K | 5 | 70 / 76 | 773 / 903 | 3.1 ms | 0 MB | 9 us | 0 | | HDD XFS 16K | 5 | 73 / 74 | 963 / 1225 | 3.2 ms | 0 MB | 8 us | 0 | | SSD-loop XFS 4K | 5 | 596 / 1061 | 1659 / 1951 | 1.3 ms | 0 MB | 5 us | 0 | | SSD-loop XFS 16K | 5 | 473 / 898 | 1632 / 1655 | 1.6 ms | 0 MB | 6 us | 0 | Caveat: HDD "cold" read speeds of 800 to 1600 MB/s are not real disk speed. drop_caches clears only the guest cache; the Proxmox host ZFS ARC still holds the data. Write speed (~72 MB/s) is the honest HDD number. Sequential throughput is the same for ext4, XFS 4K and 16K. `cp --reflink=always` fails on ext4 as expected, so the CAS needs hardlinks there (or XFS). ### d) SQLite WAL, 10k single-row transactions (commit each), tx/s median / p95 | fs | n | synchronous=FULL | FULL p99 latency ms | NORMAL | |---|---|---|---|---| | HDD ext4 | 3 | 96 / 97 | 36 | 4614 / 4756 | | HDD XFS 4K | 3 | 95 / 97 | 38 | 4349 / 4384 | | HDD XFS 16K | 3 | 79 / 83 | 40 | 4393 / 4490 | | SSD-loop XFS 4K | 5 | 115 / 116 | 18 | 16961 / 17309 | | SSD-loop XFS 16K | 5 | 114 / 115 | 18 | 14222 / 16730 | FULL is ~10 ms per commit on both disks (the zvol sync-write cost), so ~100 commits/s max per DB. NORMAL is 45 to 150x faster and does not fsync per commit. The fs and block size make no real difference. 16K was slightly slower on HDD FULL (79 vs 95 tx/s). ### Recommendation 1. **Filesystem: XFS 4K block** (`mkfs.xfs -m reflink=1`) for everything, text and attachments on the same fs. It is the only option that keeps a note save at ~26 ms while a big file is being copied or uploaded (ext4 stalls for seconds), and it gives real reflinks for the CAS dedupe (3 ms, 0 extra space, vs 315 MB per copy on ext4). 2. **Not 16K blocks.** No measured win on any workload, slower on cold read and SQLite FULL on HDD, wastes space for 1 to 20 KB notes, and it is still flagged EXPERIMENTAL in 6.12. 3. **Text and attachments:** one XFS volume is fine. If the owner later wants isolation, put attachments/`.cas` on a separate XFS filesystem (reflink only works inside one fs, so the CAS and the attachment files that point to it must stay together), and keep the notes plus SQLite DBs on the SSD volume. Notes on SSD cost less than a tenth of the HDD time for read/walk. 4. **SQLite:** WAL with `synchronous=NORMAL` for the index/search DBs (can be rebuilt from the markdown files); FULL only if we ever treat the DB as source of truth. Batch writes: the per-commit cost is ~10 ms. 5. **App design:** the atomic recipe costs 6 to 9 ms per file at best (HDD), so bulk import must run parallel (32 threads gave ~100 to 170 files/s on HDD) and skip the dir fsync per file by syncing each shard dir once per batch. ### Caveats - Loop-backed SSD numbers are less accurate (loop adds a layer, and the first attempt hung the VM in writeback until I switched to direct-io loops and disabled wbt on sda). Treat them as 4K vs 16K only. - Everything sits on ZFS zvols on the host, so absolute fsync latency (~10 ms) reflects the zvol sync path. A real local SSD/HDD will have different fsync cost; the relative fs differences (ext4 stalls under load, XFS reflinks) should carry over. - Cold reads are cold only in the guest (see above). - HDD runs for (a), (b under copy) and (d) are n=3, not 5, for time. "p95" with n=3 or 5 is effectively the worst run. - The bulk workloads use 32 threads for write phases; single-threaded would be much slower on this zvol (~40 ms per file). - Both disks were used by one workload at a time; no multi-user mixing. - 16K XFS cannot be combined with ext4-style comparisons of block size alone; ext4 was also not tested at 1K/ 16K (ext4 cannot do >4K blocks on x86 anyway). ### What cannot be tested from inside the VM, and the disks to add The zvol `volblocksize` (default 16K on current OpenZFS) and the ZFS recordsize are set on the host, and a zvol's volblocksize cannot be changed after creation. The VM disks sda and sdb both share one value now. To compare 4K vs 16K vs 64K volblocksize, please add these disks to the perf VM (all `cache=none`, `discard=on`, `iothread=1`, 40 GB each is enough): 1. `hdd-vbs4k`: zvol on the HDD pool, `volblocksize=4k` 2. `hdd-vbs16k`: zvol on the HDD pool, `volblocksize=16k` 3. `hdd-vbs64k`: zvol on the HDD pool, `volblocksize=64k` 4. `ssd-vbs4k`: zvol on the NVMe pool, `volblocksize=4k` 5. `ssd-vbs16k`: zvol on the NVMe pool, `volblocksize=16k` 6. `ssd-vbs64k`: zvol on the NVMe pool, `volblocksize=64k` Also useful: tell me the pool settings that matter (sync=standard/always, compression, SLOG present or not, ashift), and one extra unmounted 40 GB disk on the NVMe pool so the SSD can be tested as a real block device without the loop layer (replaces the loop files). With those I would rerun the same scripts with XFS 4K on each. Reproduce: `/root/bench/mount.sh` then `python3 /root/bench/bench.py <fs> <a|b|c|d> <runs>`. Raw results: `/root/bench/results/*.jsonl` on the VM.
Author
Owner

Storage on Proxmox for databases: research (2026-10-14), from kayg's question "is CoW good for databases?"

Recommendation: zvols with XFS inside the guest on both pools. Not virtiofs.

  • virtiofs:
    • virtiofsd returns ENOSYS for every ioctl, so reflink (FICLONE) can't work. Checked in source, virtiofsd 4bfa712.
    • It is slower on metadata-heavy work, and it blocks VM snapshots and migration.
    • ZFS block cloning under it is still getting corruption fixes (2.4.2 and 2.4.4).
  • App data (zfs-nvme):
    • zvol settings: volblocksize 16K (default), lz4, primarycache=all, logbias=latency, sync=standard.
    • VM disk: virtio-scsi-single, iothread=1, cache=none, aio=io_uring, discard, ssd=1.
    • Guest: XFS -b 4096 with reflink=1, plus the fstrim.timer.
  • User data (zfs-hdd): volblocksize 16K (benchmark 64K against it), lz4, primarycache=all. Add a mirrored NVMe SLOG (about 16 GB), or a special vdev on ZFS 2.4; otherwise every note-save fsync waits on HDD seeks. Keep the pool under 70% full.
  • SQLite:
    • Keep page_size=4096; bigger pages multiply the bytes written per tiny commit.
    • WAL; synchronous=FULL for auth and history, NORMAL for the indexes we can rebuild.
    • The biggest lever is group commit for history writes.
  • Watch out: primarycache=metadata turns every 4K write into a 16K read-modify-write from disk.

Host commands:

zfs create -o compression=lz4 -o atime=off -o primarycache=all -o logbias=latency zfs-nvme/calternal
zfs create -o compression=lz4 -o atime=off -o primarycache=all zfs-hdd/calternal
pvesm add zfspool calt-nvme --pool zfs-nvme/calternal --blocksize 16k --sparse 1 --content images
pvesm add zfspool calt-hdd  --pool zfs-hdd/calternal  --blocksize 16k --sparse 1 --content images
qm set <vmid> --scsihw virtio-scsi-single
qm set <vmid> --scsi2 calt-nvme:<GiB>,cache=none,aio=io_uring,iothread=1,discard=on,ssd=1
qm set <vmid> --scsi3 calt-hdd:<GiB>,cache=none,aio=io_uring,iothread=1,discard=on,ssd=0
zpool add zfs-hdd log mirror /dev/disk/by-id/<nvmeA>-partN /dev/disk/by-id/<nvmeB>-partN   # if NVMe space allows

Not verified:

  • whether zvol access bypasses ARC with cache=none;
  • kayg's pool layout: raidz or mirror, any existing SLOG, and whether the NVMe drives have power-loss protection.

Benchmark plan to confirm: zvol 16K vs 8K (NVMe) and 16K vs 64K with and without a SLOG (HDD); a history-commit workload, note saves under a copy, fio, reflink and aging. Pass rule: p99 save under 50 ms under load, and p99 history commit under 10 ms. This needs Proxmox host access for the perf VM's disks.

## Storage on Proxmox for databases: research (2026-10-14), from kayg's question "is CoW good for databases?" **Recommendation: zvols with XFS inside the guest on both pools. Not virtiofs.** - **virtiofs:** - virtiofsd returns ENOSYS for every ioctl, so reflink (FICLONE) can't work. Checked in source, virtiofsd 4bfa712. - It is slower on metadata-heavy work, and it blocks VM snapshots and migration. - ZFS block cloning under it is still getting corruption fixes (2.4.2 and 2.4.4). - **App data (zfs-nvme):** - zvol settings: volblocksize 16K (default), lz4, primarycache=all, logbias=latency, sync=standard. - VM disk: virtio-scsi-single, iothread=1, cache=none, aio=io_uring, discard, ssd=1. - Guest: XFS -b 4096 with reflink=1, plus the fstrim.timer. - **User data (zfs-hdd):** volblocksize 16K (benchmark 64K against it), lz4, primarycache=all. **Add a mirrored NVMe SLOG** (about 16 GB), or a special vdev on ZFS 2.4; otherwise every note-save fsync waits on HDD seeks. Keep the pool under 70% full. - **SQLite:** - Keep `page_size=4096`; bigger pages multiply the bytes written per tiny commit. - WAL; `synchronous=FULL` for auth and history, `NORMAL` for the indexes we can rebuild. - The biggest lever is group commit for history writes. - **Watch out:** `primarycache=metadata` turns every 4K write into a 16K read-modify-write from disk. **Host commands:** ``` zfs create -o compression=lz4 -o atime=off -o primarycache=all -o logbias=latency zfs-nvme/calternal zfs create -o compression=lz4 -o atime=off -o primarycache=all zfs-hdd/calternal pvesm add zfspool calt-nvme --pool zfs-nvme/calternal --blocksize 16k --sparse 1 --content images pvesm add zfspool calt-hdd --pool zfs-hdd/calternal --blocksize 16k --sparse 1 --content images qm set <vmid> --scsihw virtio-scsi-single qm set <vmid> --scsi2 calt-nvme:<GiB>,cache=none,aio=io_uring,iothread=1,discard=on,ssd=1 qm set <vmid> --scsi3 calt-hdd:<GiB>,cache=none,aio=io_uring,iothread=1,discard=on,ssd=0 zpool add zfs-hdd log mirror /dev/disk/by-id/<nvmeA>-partN /dev/disk/by-id/<nvmeB>-partN # if NVMe space allows ``` **Not verified:** - whether zvol access bypasses ARC with cache=none; - kayg's pool layout: raidz or mirror, any existing SLOG, and whether the NVMe drives have power-loss protection. **Benchmark plan to confirm:** zvol 16K vs 8K (NVMe) and 16K vs 64K with and without a SLOG (HDD); a history-commit workload, note saves under a copy, fio, reflink and aging. Pass rule: p99 save under 50 ms under load, and p99 history commit under 10 ms. This needs Proxmox host access for the perf VM's disks.
Author
Owner

4K vs 16K volblocksize benchmark (2026-10-14)

Perf VM, XFS 4K (mkfs.xfs -b size=4096 -m reflink=1,crc=1, noatime) on every volume except root. 3 runs each, caches dropped between phases. Medians over the runs. Script: /root/bench/z4.py, driver /root/bench/z4all.sh / z4rest.sh, raw data /root/bench/results/z4.jsonl. Run only after the other agent's perf run (M4) had finished.

Volumes

label what volblocksize
z4-nvme sde (was sdc, replaced by kayg with a 64G disk; it now reports ROTA=0), XFS 4K 4K, zfs-nvme
z4-hdd sdd 100G, XFS 4K 4K, zfs-hdd
z16-hdd sdb2 (33G), XFS 4K, the existing partition from the earlier bench 16K, zfs-hdd
root16-ext4 plain dir on / (sda1). Root is ext4, so this is a filesystem difference as well as a block-size one 16K, zfs-nvme
loop16-xfs4k sparse file on root, loop with direct-io, XFS 4K. Loop-backed, less accurate 16K, zfs-nvme

SQLite history (WAL, 4 KiB pages, one tx per 200-2000 B blob into a table plus FTS5; 20k rows preloaded; 4 FTS reader processes, each sleeping 5 ms between queries). Commit latency, ms, median of 3 runs

FULL = 2000 commits per run, NORMAL = 4000.

volume sync p50 p99 p99.9 tx/s
z4-nvme (4K) FULL 7.7 76 260 91
root16-ext4 (16K) FULL 10.7 93 282 65
loop16-xfs4k (16K, loop) FULL 24.2 192 955 27
z4-hdd (4K) FULL 17.6 149 285 43
z16-hdd (16K) FULL 18.2 163 514 41
z4-nvme NORMAL 0.3 50 146 412
root16-ext4 NORMAL 0.3 46 190 431
loop16-xfs4k NORMAL 0.3 61 200 340
z4-hdd NORMAL 0.3 190 438 184
z16-hdd NORMAL 0.3 171 405 193

NORMAL p99 of 45-190 ms is the WAL checkpoint (it fsyncs) landing inside a writer commit, with a 4-reader load. tx/s is capped by the Python loop and the readers, not by the disk. Pass rule from the research comment is p99 history commit < 10 ms: nothing passes at p99, not even NORMAL, and only NORMAL p50 passes. So the history writer needs group commit and a checkpoint off the commit path (wal_autocheckpoint off plus a background PASSIVE checkpoint thread), regardless of volblocksize.

Note save: atomic write (tmp, fsync, rename, fsync dir), 500 B to 30 KB, ms

volume no copy: p50 / p99 with concurrent looping 1 GB cp: p50 / p99 saves per run
z4-nvme (4K) 23 / 79 33 / 1601 200
root16-ext4 (16K) 50 / 238 263 / 37591 (1 run only) 200
root16-ext4 20 / 28 49 / 608 30 (3 runs)
loop16-xfs4k (16K, loop) 33 / 218 416 / 2259 200
z4-hdd (4K) 30 / 158 (n=200) 10610 / 30426 30
z16-hdd (16K) 42 / 127 20954 / 41783 30

With n=30 the p99 is the max, so treat it as the worst run. I cut the HDD copy case to 30 saves because 200 saves took over half an hour per run. The ext4 root case with 200 saves reproduced the earlier stall (p99 37 s); at 30 saves the copy had not built up enough dirty data yet.

fio on the volume (psync, buffered, 1 GiB file). 4k randwrite, iodepth=1, fdatasync after every write, 15 s; 1M sequential write 1 GiB with end_fsync

volume randwrite4k fdatasync IOPS seq 1M write MB/s
z4-nvme (4K) 65 406
root16-ext4 (16K) 27 404
loop16-xfs4k (16K, loop) 31 401
z4-hdd (4K) 48 70
z16-hdd (16K) 29 73

That is ~15 ms per synced 4K write on 4K NVMe, ~21 ms on 4K HDD, vs 34-37 ms on the 16K volumes. Run-to-run spread was large, so the factor-of-2 is suggestive, not proven. (fio's own clat is only the 40 us buffered write; the fsync latency is what the IOPS reflects.)

z4-nvme 0.1 s, z4-hdd 0.1 s, z16-hdd 0.0 s, loop XFS 0.0 s; 0 MB extra space on all. ext4 root does not support it (fails as expected).

Recommendation

  1. Use 4K volblocksize with XFS 4K over 16K, on both pools. For synced small writes it was equal or better everywhere: FULL commit p50 7.7 ms vs 10.7 ms (NVMe), fdatasync 4K write IOPS about 1.6 to 2.4x higher, sequential and reflink are identical. Nothing measured favoured 16K. The one 4K risk is ZFS metadata/compression overhead and more ARC/space overhead per volume, which a 64G test volume can't show; if capacity matters, watch zfs list -o used,refer after loading.
  2. XFS vs ext4 is not a safe call from this run for the stall case: ext4 root stalled to 37 s in one 200-save run, as before. But XFS also stalled under a looping copy here: 4K NVMe p99 1.6 s, HDD p50 10 to 21 s. The earlier #14 bench saw XFS flat (~26 ms) under the same kind of copy, so something differs now (HDD pool load from other VMs or a different host ARC/txg state is my guess; I did not verify it). Mitigation that doesn't depend on the filesystem: the app should cap dirty data from uploads (stream attachments with periodic sync_file_range/fdatasync every few MB, or O_DIRECT for big files) and do note saves on a separate volume from attachments. A separate NVMe volume for notes and DBs, HDD only for attachments, remains the clear way to meet the p99 < 50 ms pass rule.
  3. HDD pool needs the SLOG (or a special vdev) before it can hold notes: fsync-bound work on HDD is 30 ms p50 and stalls to tens of seconds under a copy. Notes on HDD without a SLOG will fail the pass rule.
  4. SQLite: keep page_size 4096 and WAL; FULL for auth/history only with group commit; NORMAL for rebuildable indexes; move checkpoints off the commit path.

Caveats

  • sdc was replaced mid-run: kayg resized it to 64G, which hot-plugged it as sde. The ssd flag now shows (ROTA=0); the earlier ROTA=1 had no effect on I/O. I reformatted it as XFS 4K.
  • The NVMe "16K" data points are not a fair comparison: root is ext4 (not XFS), and the other is loop-backed XFS 4K on root, which adds the loop layer (and nests the latency of the 16K zvol under it; its FULL commit numbers are ~3x worse, which is likely loop overhead). The HDD pair (z4-hdd vs z16-hdd) is the clean one: both XFS 4K, same pool, direct block devices.
  • z16-hdd is a 33G partition of sdb, z4-hdd is a whole 100G disk; same pool, but different position on the shared zvol layout is unknowable from here.
  • Save-under-copy on HDD and the ext4 case ran 30 saves (p99 = max). The n=200 HDD no-copy rows are fine.
  • Windows where another VM load on the same host pool could affect results are not controlled for.
  • To make the NVMe comparison fair, add (all cache=none, discard=on, iothread=1, ssd=1, ~40G each) two more zfs-nvme zvols: 16K and 8K (and 64K if that is a candidate), formatted XFS 4K as data disks, so the only difference to z4-nvme is volblocksize. Same for 8K/64K on HDD if the HDD default is in question. Report the pool's sync, compression, ashift and whether a SLOG exists too; I could not see them from the guest.
## 4K vs 16K volblocksize benchmark (2026-10-14) Perf VM, XFS 4K (`mkfs.xfs -b size=4096 -m reflink=1,crc=1`, noatime) on every volume except root. 3 runs each, caches dropped between phases. Medians over the runs. Script: `/root/bench/z4.py`, driver `/root/bench/z4all.sh` / `z4rest.sh`, raw data `/root/bench/results/z4.jsonl`. Run only after the other agent's perf run (M4) had finished. **Volumes** | label | what | volblocksize | |---|---|---| | z4-nvme | sde (was sdc, replaced by kayg with a 64G disk; it now reports ROTA=0), XFS 4K | 4K, zfs-nvme | | z4-hdd | sdd 100G, XFS 4K | 4K, zfs-hdd | | z16-hdd | sdb2 (33G), XFS 4K, the existing partition from the earlier bench | 16K, zfs-hdd | | root16-ext4 | plain dir on `/` (sda1). **Root is ext4**, so this is a filesystem difference as well as a block-size one | 16K, zfs-nvme | | loop16-xfs4k | sparse file on root, loop with direct-io, XFS 4K. **Loop-backed, less accurate** | 16K, zfs-nvme | ### SQLite history (WAL, 4 KiB pages, one tx per 200-2000 B blob into a table plus FTS5; 20k rows preloaded; 4 FTS reader processes, each sleeping 5 ms between queries). Commit latency, ms, median of 3 runs FULL = 2000 commits per run, NORMAL = 4000. | volume | sync | p50 | p99 | p99.9 | tx/s | |---|---|---|---|---|---| | z4-nvme (4K) | FULL | 7.7 | 76 | 260 | 91 | | root16-ext4 (16K) | FULL | 10.7 | 93 | 282 | 65 | | loop16-xfs4k (16K, loop) | FULL | 24.2 | 192 | 955 | 27 | | z4-hdd (4K) | FULL | 17.6 | 149 | 285 | 43 | | z16-hdd (16K) | FULL | 18.2 | 163 | 514 | 41 | | z4-nvme | NORMAL | 0.3 | 50 | 146 | 412 | | root16-ext4 | NORMAL | 0.3 | 46 | 190 | 431 | | loop16-xfs4k | NORMAL | 0.3 | 61 | 200 | 340 | | z4-hdd | NORMAL | 0.3 | 190 | 438 | 184 | | z16-hdd | NORMAL | 0.3 | 171 | 405 | 193 | NORMAL p99 of 45-190 ms is the WAL checkpoint (it fsyncs) landing inside a writer commit, with a 4-reader load. tx/s is capped by the Python loop and the readers, not by the disk. Pass rule from the research comment is p99 history commit < 10 ms: **nothing passes at p99, not even NORMAL**, and only NORMAL p50 passes. So the history writer needs group commit and a checkpoint off the commit path (wal_autocheckpoint off plus a background `PASSIVE` checkpoint thread), regardless of volblocksize. ### Note save: atomic write (tmp, fsync, rename, fsync dir), 500 B to 30 KB, ms | volume | no copy: p50 / p99 | with concurrent looping 1 GB `cp`: p50 / p99 | saves per run | |---|---|---|---| | z4-nvme (4K) | 23 / 79 | 33 / **1601** | 200 | | root16-ext4 (16K) | 50 / 238 | 263 / **37591** (1 run only) | 200 | | root16-ext4 | 20 / 28 | 49 / 608 | 30 (3 runs) | | loop16-xfs4k (16K, loop) | 33 / 218 | 416 / **2259** | 200 | | z4-hdd (4K) | 30 / 158 (n=200) | **10610 / 30426** | 30 | | z16-hdd (16K) | 42 / 127 | **20954 / 41783** | 30 | With n=30 the p99 is the max, so treat it as the worst run. I cut the HDD copy case to 30 saves because 200 saves took over half an hour per run. The ext4 root case with 200 saves reproduced the earlier stall (p99 37 s); at 30 saves the copy had not built up enough dirty data yet. ### fio on the volume (psync, buffered, 1 GiB file). 4k randwrite, iodepth=1, fdatasync after every write, 15 s; 1M sequential write 1 GiB with end_fsync | volume | randwrite4k fdatasync IOPS | seq 1M write MB/s | |---|---|---| | z4-nvme (4K) | 65 | 406 | | root16-ext4 (16K) | 27 | 404 | | loop16-xfs4k (16K, loop) | 31 | 401 | | z4-hdd (4K) | 48 | 70 | | z16-hdd (16K) | 29 | 73 | That is ~15 ms per synced 4K write on 4K NVMe, ~21 ms on 4K HDD, vs 34-37 ms on the 16K volumes. Run-to-run spread was large, so the factor-of-2 is suggestive, not proven. (fio's own clat is only the 40 us buffered write; the fsync latency is what the IOPS reflects.) ### Reflink: `cp -r --reflink=always` of a 1 GB tree (50 x 10 MB files) z4-nvme 0.1 s, z4-hdd 0.1 s, z16-hdd 0.0 s, loop XFS 0.0 s; 0 MB extra space on all. ext4 root does not support it (fails as expected). ### Recommendation 1. **Use 4K volblocksize with XFS 4K** over 16K, on both pools. For synced small writes it was equal or better everywhere: FULL commit p50 7.7 ms vs 10.7 ms (NVMe), fdatasync 4K write IOPS about 1.6 to 2.4x higher, sequential and reflink are identical. Nothing measured favoured 16K. The one 4K risk is ZFS metadata/compression overhead and more ARC/space overhead per volume, which a 64G test volume can't show; if capacity matters, watch `zfs list -o used,refer` after loading. 2. **XFS vs ext4 is not a safe call from this run for the stall case**: ext4 root stalled to 37 s in one 200-save run, as before. But XFS also stalled under a looping copy here: 4K NVMe p99 1.6 s, HDD p50 10 to 21 s. The earlier #14 bench saw XFS flat (~26 ms) under the same kind of copy, so something differs now (HDD pool load from other VMs or a different host ARC/txg state is my guess; I did not verify it). Mitigation that doesn't depend on the filesystem: the app should cap dirty data from uploads (stream attachments with periodic `sync_file_range`/fdatasync every few MB, or O_DIRECT for big files) and do note saves on a separate volume from attachments. A separate NVMe volume for notes and DBs, HDD only for attachments, remains the clear way to meet the p99 < 50 ms pass rule. 3. **HDD pool needs the SLOG (or a special vdev) before it can hold notes**: fsync-bound work on HDD is 30 ms p50 and stalls to tens of seconds under a copy. Notes on HDD without a SLOG will fail the pass rule. 4. **SQLite**: keep page_size 4096 and WAL; FULL for auth/history only with group commit; NORMAL for rebuildable indexes; move checkpoints off the commit path. ### Caveats - sdc was replaced mid-run: kayg resized it to 64G, which hot-plugged it as sde. The ssd flag now shows (ROTA=0); the earlier ROTA=1 had no effect on I/O. I reformatted it as XFS 4K. - The NVMe "16K" data points are not a fair comparison: root is **ext4** (not XFS), and the other is **loop-backed XFS 4K on root**, which adds the loop layer (and nests the latency of the 16K zvol under it; its FULL commit numbers are ~3x worse, which is likely loop overhead). The HDD pair (z4-hdd vs z16-hdd) is the clean one: both XFS 4K, same pool, direct block devices. - z16-hdd is a 33G partition of sdb, z4-hdd is a whole 100G disk; same pool, but different position on the shared zvol layout is unknowable from here. - Save-under-copy on HDD and the ext4 case ran 30 saves (p99 = max). The n=200 HDD no-copy rows are fine. - Windows where another VM load on the same host pool could affect results are not controlled for. - To make the NVMe comparison fair, add (all `cache=none`, `discard=on`, `iothread=1`, `ssd=1`, ~40G each) two more zfs-nvme zvols: **16K** and **8K** (and 64K if that is a candidate), formatted XFS 4K as data disks, so the only difference to z4-nvme is volblocksize. Same for 8K/64K on HDD if the HDD default is in question. Report the pool's `sync`, compression, ashift and whether a SLOG exists too; I could not see them from the guest.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal#14
No description provided.