From 0e5e60512e71fef07a5d1fee984d6fc549cee26a Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Mon, 12 Feb 2024 13:57:01 -0500 Subject: [PATCH] LU-15033 llite: Increase default RA sizes The default max_readahead_mb is 1/32 of all cached pages, which doesn't make much sense but isn't usually a problem since most real nodes have very high RAM or it is tuned to larger values. It is reduced further for the per-file limit, which is also reasonable. However, on test VMs with smaller RAM sizes, this results in hilariously tiny max_read_ahead_per_file_mb values, like 20. This is small enough it causes extra misses because two RPCs cannot be reliably sent. This edge case isn't important for performance, but it makes small scale testing of readahead nearly impossible. To avoid this, we add a minimum readahead requirement of 256 MiB, which is used unless it's > half of RAM. This should avoid this case on test VMs without changing the behavior for real clients unless they are extremely small. Signed-off-by: Patrick Farrell Change-Id: Ie8aab6b04ad520e4633d634d846e7ef23cc91ced Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/46475 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Sebastien Buisson Reviewed-by: Oleg Drokin --- lustre/llite/llite_internal.h | 4 ++++ lustre/llite/llite_lib.c | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 82cb06d..5690f0d 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -690,6 +690,10 @@ static inline void ll_inode_unlock(struct inode *inode) /* default read-ahead on a given client mountpoint. */ #define SBI_DEFAULT_READ_AHEAD_MAX MiB_TO_PAGES(1024UL) +/* on small nodes (ie, testing VMs), we need at least this much to make + * readahead easily testable + */ +#define SBI_DEFAULT_READ_AHEAD_MIN MiB_TO_PAGES(256UL) /* default read-ahead for a single file descriptor */ #define SBI_DEFAULT_READ_AHEAD_PER_FILE_MAX MiB_TO_PAGES(256UL) diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 9cff0f1..7e67cf5 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -158,6 +158,14 @@ static struct ll_sb_info *ll_init_sbi(struct lustre_sb_info *lsi) sbi->ll_ra_info.ra_max_pages = min(pages / 32, SBI_DEFAULT_READ_AHEAD_MAX); + /* on very small nodes (ie, testing VMs), we need a minimum readahead + * size to get sane testing behavior, so we try to enforce this + * minimum. This only kicks in at small RAM sizes, so generally won't + * affect real clients + */ + if (sbi->ll_ra_info.ra_max_pages < SBI_DEFAULT_READ_AHEAD_MIN) + sbi->ll_ra_info.ra_max_pages = + min(pages / 2, SBI_DEFAULT_READ_AHEAD_MIN); sbi->ll_ra_info.ra_max_pages_per_file = min(sbi->ll_ra_info.ra_max_pages / 4, SBI_DEFAULT_READ_AHEAD_PER_FILE_MAX); -- 1.8.3.1