Commit bb00a0b
committed
mac: improve posix_fadvise shim
This builds upon the best effort macOS cache invalidation work by
DeveloperEcosystemEngineering@apple.com's by shimming even more of
posix_advise() on macOS:
- POSIX_FADV_NORMAL is ignored
- POSIX_FADV_SEQUENTIAL/POSIX_FADV_RANDOM are mapped to enable/disable
readahead via fcntl(..., F_RDAHEAD, ...)
To paraphrase from the commit that was done for similar reasons
targeting Windows (see 8300eba ("windowsaio: add best effort cache
invalidation")):
This change may make default bandwidth speeds on macOS look lower
compared to older versions of fio but this matches the behaviour of fio
on other platforms with invalidation (such as Linux) because we are
trying to avoid measuring cache reuse (unless invalidate=0 is set).
The impact of invalidation is demonstrated by the bandwidths achieved by
the following jobs running on a SSD of an otherwise idle Intel Mac with
16GBytes of RAM:
./fio --stonewall --size=128M --ioengine=posixaio --filename=fio.tmp --iodepth=64 \
--bs=4k --invalidate=0 --direct=0 \
--name=create --rw=write \
--name=cached --rw=randread --loops=2 \
--name=invalidated --rw=randread --loops=2 --invalidate=1
[...]
cached: (groupid=1, jobs=1): err= 0: pid=32517: Sat May 17 18:37:57 2025
read: IOPS=228k, BW=892MiB/s (935MB/s)(256MiB/287msec)
[...]
invalidated: (groupid=2, jobs=1): err= 0: pid=32518: Sat May 17 18:37:57 2025
read: IOPS=43.1k, BW=168MiB/s (176MB/s)(256MiB/1522msec)
The impact of being able to tune readahead can be seen below:
./fio --filename=fio.tmp --stonewall --size=128M --filename=fio.tmp --bs=4k \
--name=precache --rw=read --bs=128k \
--name=cached --rw=read \
--name=uncached-readahead --rw=read --invalidate=1 \
--name=uncached-no-readahead --rw=read --invalidate=1 --fadvise=random
[...]
cached: (groupid=1, jobs=1): err= 0: pid=32600: Sat May 17 18:49:22 2025
read: IOPS=349k, BW=1362MiB/s (1428MB/s)(128MiB/94msec)
--
uncached-readahead: (groupid=2, jobs=1): err= 0: pid=32601: Sat May 17 18:49:22 2025
read: IOPS=315k, BW=1231MiB/s (1291MB/s)(128MiB/104msec)
--
uncached-no-readahead: (groupid=3, jobs=1): err= 0: pid=32602: Sat May 17 18:49:22 2025
read: IOPS=40.8k, BW=159MiB/s (167MB/s)(128MiB/803msec)
Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>1 parent 6979c18 commit bb00a0b
3 files changed
+45
-23
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | 29 | | |
39 | 30 | | |
40 | 31 | | |
41 | 32 | | |
42 | 33 | | |
43 | 34 | | |
44 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | | - | |
18 | | - | |
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
| |||
135 | 134 | | |
136 | 135 | | |
137 | 136 | | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | 137 | | |
146 | 138 | | |
147 | 139 | | |
| |||
154 | 146 | | |
155 | 147 | | |
156 | 148 | | |
157 | | - | |
| 149 | + | |
158 | 150 | | |
159 | 151 | | |
160 | 152 | | |
161 | 153 | | |
162 | 154 | | |
163 | 155 | | |
164 | | - | |
| 156 | + | |
165 | 157 | | |
166 | 158 | | |
167 | 159 | | |
168 | 160 | | |
169 | 161 | | |
170 | 162 | | |
171 | 163 | | |
172 | | - | |
| 164 | + | |
173 | 165 | | |
174 | 166 | | |
175 | 167 | | |
| |||
178 | 170 | | |
179 | 171 | | |
180 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
946 | 946 | | |
947 | 947 | | |
948 | 948 | | |
949 | | - | |
| 949 | + | |
950 | 950 | | |
951 | 951 | | |
952 | 952 | | |
| |||
0 commit comments