Commit 44178ac
committed
Implement uncached prefetch.
Before this change primarycache property was handled only on dbuf
layer, controlling dbuf cache and through a hack an ARC evictions.
Since speculative prefetcher is implemented on ARC level, it had
to be disabled for uncacheable buffers because otherwise falsely
prefetched and never read buffers would stay cached in ARC.
This change gives ARC a knowledge about uncacheable buffers. It
is passed to arc_read() and arc_write() and stored in ARC header.
When remove_reference() drops last reference on the ARC header, it
can either immediately destroy it, or if it is marked as prefetch,
put it into new arc_uncached state. That state is scanned every
second, looking for stale buffers that were not demand read (in
which case they are evicted immediately).
To handle cases of short or misaligned reads, this change tracks
at dbuf layer buffers that were read from the beginning, but not
to the end. It is assumed that such buffers may receive further
reads, and so they are stored in dbuf cache. If some of following
reads reaches the end of such buffer, it is immediately evicted.
Otherwise it will follow regular dbuf cache eviction and will be
evicted also from ARC the same moment. Since dbuf layer does not
know the actual file size, this logic is not applied to the last
buffers of dnodes, which are always evicted same as before.
Since uncacheable buffers should no longer stay in ARC for long,
this patch also tries to optimize I/O by allocating ARC physical
buffers as linear to allow buffer sharing. It allows to avoid
one of two memory copies for uncompressed data for both reads and
writes by the cost of some higher KVA usage in case of prefetch.
With the combination of enabled prefetch and avoided memory copy
this change improves sequential single-threaded read speed from
a wide NVMe pool from 2049 to 3932 MiB/s. During write profiler
shows 22% reduction of unhalted CPU cycles at the same throughput
of 3653 MiB/s.
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.1 parent 2407d0f commit 44178ac
File tree
10 files changed
+237
-138
lines changed- include
- os/linux/zfs/sys
- sys
- module
- os/freebsd/zfs
- zfs
10 files changed
+237
-138
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| 111 | + | |
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
| |||
392 | 393 | | |
393 | 394 | | |
394 | 395 | | |
| 396 | + | |
395 | 397 | | |
396 | 398 | | |
397 | 399 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
118 | 119 | | |
119 | 120 | | |
120 | 121 | | |
| |||
228 | 229 | | |
229 | 230 | | |
230 | 231 | | |
| 232 | + | |
231 | 233 | | |
232 | 234 | | |
233 | 235 | | |
| |||
301 | 303 | | |
302 | 304 | | |
303 | 305 | | |
304 | | - | |
305 | | - | |
| 306 | + | |
| 307 | + | |
306 | 308 | | |
307 | 309 | | |
308 | 310 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| |||
542 | 543 | | |
543 | 544 | | |
544 | 545 | | |
| 546 | + | |
545 | 547 | | |
546 | 548 | | |
547 | 549 | | |
| |||
744 | 746 | | |
745 | 747 | | |
746 | 748 | | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
747 | 764 | | |
748 | 765 | | |
749 | 766 | | |
| |||
900 | 917 | | |
901 | 918 | | |
902 | 919 | | |
| 920 | + | |
903 | 921 | | |
904 | 922 | | |
905 | 923 | | |
| |||
1006 | 1024 | | |
1007 | 1025 | | |
1008 | 1026 | | |
| 1027 | + | |
1009 | 1028 | | |
1010 | 1029 | | |
1011 | 1030 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
| 59 | + | |
58 | 60 | | |
59 | 61 | | |
60 | 62 | | |
| |||
321 | 323 | | |
322 | 324 | | |
323 | 325 | | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
324 | 329 | | |
325 | 330 | | |
326 | 331 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
457 | 457 | | |
458 | 458 | | |
459 | 459 | | |
460 | | - | |
| 460 | + | |
461 | 461 | | |
462 | | - | |
| 462 | + | |
463 | 463 | | |
464 | 464 | | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | 465 | | |
470 | 466 | | |
471 | 467 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
366 | 366 | | |
367 | 367 | | |
368 | 368 | | |
369 | | - | |
| 369 | + | |
370 | 370 | | |
371 | 371 | | |
372 | | - | |
| 372 | + | |
373 | 373 | | |
374 | 374 | | |
375 | 375 | | |
| |||
424 | 424 | | |
425 | 425 | | |
426 | 426 | | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
427 | 440 | | |
428 | 441 | | |
429 | 442 | | |
| |||
0 commit comments