]> git.hungrycats.org Git - bees/commitdiff
readahead: flush the readahead cache based on time, not extent count
authorZygo Blaxell <bees@furryterror.org>
Tue, 11 Mar 2025 18:46:40 +0000 (14:46 -0400)
committerZygo Blaxell <bees@furryterror.org>
Tue, 22 Jul 2025 04:06:11 +0000 (00:06 -0400)
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>
src/bees.cc

index a4b0b0c6cb09633838d7c6218b6a836a2323edd7..99cd7822176a7a5277606f072c3f475defc0a100 100644 (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);
        }