loader bcache: Allow readahead up to 256 kB I/Os

Prior to this commit, the loader would perform readaheads of up to
128 kB; when booting on a UFS filesystem this resulted in a series
of 160 kB reads (32 kB request + 128 kB readahead).

This commit allows readaheads to be longer, subject to a total I/O
size limit of 256 kB; i.e. 32 kB read requests will have added
readaheads of up to 224 kB.

In my testing on an EC2 c5.xlarge instance, this change reduces the
boot time by roughly 80 ms.

Reviewed by:	tsoome
MFC after:	1 week
Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D32251
This commit is contained in:
Colin Percival 2021-10-03 14:55:10 -07:00
parent 04b9b7c507
commit 248682a589

View File

@ -86,8 +86,9 @@ static u_int bcache_rablks;
#define BHASH(bc, blkno) ((blkno) & ((bc)->bcache_nblks - 1))
#define BCACHE_LOOKUP(bc, blkno) \
((bc)->bcache_ctl[BHASH((bc), (blkno))].bc_blkno != (blkno))
#define BCACHE_READAHEAD 256
#define BCACHE_READAHEAD 512
#define BCACHE_MINREADAHEAD 32
#define BCACHE_MAXIOWRA 512
static void bcache_invalidate(struct bcache *bc, daddr_t blkno);
static void bcache_insert(struct bcache *bc, daddr_t blkno);
@ -324,6 +325,8 @@ read_strategy(void *devdata, int rw, daddr_t blk, size_t size,
if (ra != 0 && ra != bc->bcache_nblks) { /* do we have RA space? */
ra = MIN(bc->ra, ra - 1);
ra = rounddown(ra, 16); /* multiple of 16 blocks */
if (ra + p_size > BCACHE_MAXIOWRA)
ra = BCACHE_MAXIOWRA - p_size;
bc->ralen = ra;
p_size += ra;
} else {