1
0
mirror of https://github.com/Zygo/bees.git synced 2025-07-31 21:13:27 +02:00

readahead: flush the readahead cache based on time, not extent count

If the extent wasn't read in the last second, chances are high that
it was evicted from the page cache.  If the extents have been evicted
from the cache by the time we grow or dedupe them, we'll take a serious
performance hit as we read them back in, one page at a time.

Use a 5-second delay to match the default writeback interval.

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
Zygo Blaxell
2025-03-11 14:46:40 -04:00
parent e87f6e9649
commit ba11d733c0

View File

@@ -228,8 +228,10 @@ bees_readahead_check(int const fd, off_t const offset, size_t const size)
auto tup = make_tuple(offset, size, stat_rv.st_dev, stat_rv.st_ino);
static mutex s_recent_mutex;
static set<decltype(tup)> s_recent;
static Timer s_recent_timer;
unique_lock<mutex> lock(s_recent_mutex);
if (s_recent.size() > BEES_MAX_EXTENT_REF_COUNT) {
if (s_recent_timer.age() > 5.0) {
s_recent_timer.reset();
s_recent.clear();
BEESCOUNT(readahead_clear);
}