aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Percival <cperciva@FreeBSD.org>2021-10-03 21:55:10 +0000
committerColin Percival <cperciva@FreeBSD.org>2021-10-03 21:55:10 +0000
commit248682a589159619aa5f2019e415a423e849e327 (patch)
tree03750dce53c262778dcb22a505151314e58b2e9d
parent04b9b7c507c52daf7b2999329a50825db098151f (diff)
downloadsrc-248682a589159619aa5f2019e415a423e849e327.tar.gz
src-248682a589159619aa5f2019e415a423e849e327.zip
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
-rw-r--r--stand/common/bcache.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/stand/common/bcache.c b/stand/common/bcache.c
index b79d609b198b..99c78b0346b7 100644
--- a/stand/common/bcache.c
+++ b/stand/common/bcache.c
@@ -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 {