Skip to content

Commit 34b3d49

Browse files
authored
Adjust prefetch parameters.
- Reduce maximum prefetch distance for 32bit platforms to 8MB as it was previously. Those systems didn't grow much probably, so better stay conservative there. - Retire array_rd_sz tunable, blocking prefetch for large requests. We should not penalize applications trying to be more efficient. The speculative prefetcher by itself has reasonable distance limits, and 1MB is not much at all these days. Reviewed-by: Allan Jude <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Alexander Motin <[email protected]> Sponsored by: iXsystems, Inc. Closes #15072
1 parent 28430b5 commit 34b3d49

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

include/sys/dmu_zfetch.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
extern "C" {
3737
#endif
3838

39-
extern uint64_t zfetch_array_rd_sz;
40-
4139
struct dnode; /* so we can reference dnode */
4240

4341
typedef struct zfetch {

man/man4/zfs.4

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,6 @@ However, this is limited by
519519
Maximum micro ZAP size.
520520
A micro ZAP is upgraded to a fat ZAP, once it grows beyond the specified size.
521521
.
522-
.It Sy zfetch_array_rd_sz Ns = Ns Sy 1048576 Ns B Po 1 MiB Pc Pq u64
523-
If prefetching is enabled, disable prefetching for reads larger than this size.
524-
.
525522
.It Sy zfetch_min_distance Ns = Ns Sy 4194304 Ns B Po 4 MiB Pc Pq uint
526523
Min bytes to prefetch per stream.
527524
Prefetch distance starts from the demand access size and quickly grows to

module/zfs/dmu.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ static int zfs_dmu_offset_next_sync = 1;
8989
* helps to limit the amount of memory that can be used by prefetching.
9090
* Larger objects should be prefetched a bit at a time.
9191
*/
92+
#ifdef _ILP32
93+
uint_t dmu_prefetch_max = 8 * 1024 * 1024;
94+
#else
9295
uint_t dmu_prefetch_max = 8 * SPA_MAXBLOCKSIZE;
96+
#endif
9397

9498
const dmu_object_type_info_t dmu_ot[DMU_OT_NUMTYPES] = {
9599
{DMU_BSWAP_UINT8, TRUE, FALSE, FALSE, "unallocated" },
@@ -552,8 +556,7 @@ dmu_buf_hold_array_by_dnode(dnode_t *dn, uint64_t offset, uint64_t length,
552556
zio = zio_root(dn->dn_objset->os_spa, NULL, NULL,
553557
ZIO_FLAG_CANFAIL);
554558
blkid = dbuf_whichblock(dn, 0, offset);
555-
if ((flags & DMU_READ_NO_PREFETCH) == 0 &&
556-
length <= zfetch_array_rd_sz) {
559+
if ((flags & DMU_READ_NO_PREFETCH) == 0) {
557560
/*
558561
* Prepare the zfetch before initiating the demand reads, so
559562
* that if multiple threads block on same indirect block, we

module/zfs/dmu_zfetch.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,19 @@ static unsigned int zfetch_max_streams = 8;
5252
static unsigned int zfetch_min_sec_reap = 1;
5353
/* max time before stream delete */
5454
static unsigned int zfetch_max_sec_reap = 2;
55+
#ifdef _ILP32
56+
/* min bytes to prefetch per stream (default 2MB) */
57+
static unsigned int zfetch_min_distance = 2 * 1024 * 1024;
58+
/* max bytes to prefetch per stream (default 8MB) */
59+
unsigned int zfetch_max_distance = 8 * 1024 * 1024;
60+
#else
5561
/* min bytes to prefetch per stream (default 4MB) */
5662
static unsigned int zfetch_min_distance = 4 * 1024 * 1024;
5763
/* max bytes to prefetch per stream (default 64MB) */
5864
unsigned int zfetch_max_distance = 64 * 1024 * 1024;
65+
#endif
5966
/* max bytes to prefetch indirects for per stream (default 64MB) */
6067
unsigned int zfetch_max_idistance = 64 * 1024 * 1024;
61-
/* max number of bytes in an array_read in which we allow prefetching (1MB) */
62-
uint64_t zfetch_array_rd_sz = 1024 * 1024;
6368

6469
typedef struct zfetch_stats {
6570
kstat_named_t zfetchstat_hits;
@@ -580,6 +585,3 @@ ZFS_MODULE_PARAM(zfs_prefetch, zfetch_, max_distance, UINT, ZMOD_RW,
580585

581586
ZFS_MODULE_PARAM(zfs_prefetch, zfetch_, max_idistance, UINT, ZMOD_RW,
582587
"Max bytes to prefetch indirects for per stream");
583-
584-
ZFS_MODULE_PARAM(zfs_prefetch, zfetch_, array_rd_sz, U64, ZMOD_RW,
585-
"Number of bytes in a array_read");

0 commit comments

Comments
 (0)