Commit 3e8cfd5
committed
libext: tune prefetch ring to N=4/M=4 from a device-queue-depth sweep
Sweep on a local-NVMe host (, ext4 4K/no-journal, O_DIRECT so reads hit the
device, 512 MiB, median of 3):
config 64K 128K 256K prefetch mem/file
N=1 M=1 ~0.69 ~0.85 ~0.85 256 KiB (~QD1)
N=4 M=2 ~1.20 - ~1.28 1 MiB
N=4 M=4 ~1.26 ~1.23 ~1.29 1 MiB <- knee
N=8 M=4 ~1.28 ~1.28 ~1.31 2 MiB
N=8 M=8 ~1.28 ~1.28 ~1.29 2 MiB
N=16 M=16 ~1.25 - ~1.21 4 MiB
Throughput climbs steeply from N=1/M=1 to the knee at N=4/M=4 (~1.28 GB/s) and
then plateaus: deeper rings or more workers give no further gain. The cap is
downstream of this code -- OSv's virtio-blk make_request() serialises submission
under a single _lock and a single virtqueue, so effective device queue depth
tops out at ~2-4 regardless of how many prefetch windows are in flight. (Linux
fio O_DIRECT on the same raw NVMe: ~1.32 GB/s @128k QD1, ~1.68 GB/s @128k QD>=2,
i.e. the device itself saturates at QD2; the remaining OSv gap is the guest
virtio-blk path, not prefetch depth.)
So N=4/M=4 is the sweet spot: same throughput as the deeper configs at half the
memory (1 MiB vs 2 MiB per open file). It also matches the prior 2-window async
design (~1.25 GB/s here) while using a general N-window ring. Make N and M
build-time tunables (-DRA_WINDOWS_N / -DRA_WORKERS_M via $(RA_FLAGS)) so the
sweep is reproducible when the virtio-blk submission path is later parallelised.
No VERIFY FAIL at any config or block size (4K/64K/128K/256K/262143/1M, files
smaller than the ring).1 parent 02a5d53 commit 3e8cfd5
2 files changed
Lines changed: 20 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
| 126 | + | |
126 | 127 | | |
127 | 128 | | |
128 | 129 | | |
129 | | - | |
130 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
131 | 146 | | |
132 | 147 | | |
133 | 148 | | |
| |||
1899 | 1914 | | |
1900 | 1915 | | |
1901 | 1916 | | |
1902 | | - | |
| 1917 | + | |
1903 | 1918 | | |
1904 | 1919 | | |
1905 | 1920 | | |
| |||
0 commit comments