From 96eb100ded098cccd31deaf65e763369fbc82016 Mon Sep 17 00:00:00 2001 From: Zygo Blaxell Date: Sun, 8 Jul 2018 10:33:30 -0400 Subject: [PATCH] bees: use readahead instead of posix_fadvise Other btrfs utils use readahead() not posix_fadvise(). There does not appear to be a performance or correctness difference between the three (none, posix_fadvise, or readahead()). Signed-off-by: Zygo Blaxell --- src/bees-context.cc | 2 +- src/bees-types.cc | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/bees-context.cc b/src/bees-context.cc index 231da5d..4b1f54f 100644 --- a/src/bees-context.cc +++ b/src/bees-context.cc @@ -313,7 +313,7 @@ BeesContext::scan_one_extent(const BeesFileRange &bfr, const Extent &e) } // OK we need to read extent now - posix_fadvise(bfr.fd(), bfr.begin(), bfr.size(), POSIX_FADV_WILLNEED); + readahead(bfr.fd(), bfr.begin(), bfr.size()); map> insert_map; set noinsert_set; diff --git a/src/bees-types.cc b/src/bees-types.cc index 3ac37af..211d87e 100644 --- a/src/bees-types.cc +++ b/src/bees-types.cc @@ -386,8 +386,8 @@ BeesRangePair::grow(shared_ptr ctx, bool constrained) BEESTRACE("e_second " << e_second); // Preread entire extent - posix_fadvise(second.fd(), e_second.begin(), e_second.size(), POSIX_FADV_WILLNEED); - posix_fadvise(first.fd(), e_second.begin() + first.begin() - second.begin(), e_second.size(), POSIX_FADV_WILLNEED); + readahead(second.fd(), e_second.begin(), e_second.size()); + readahead(first.fd(), e_second.begin() + first.begin() - second.begin(), e_second.size()); auto hash_table = ctx->hash_table(); @@ -406,7 +406,7 @@ BeesRangePair::grow(shared_ptr ctx, bool constrained) BEESCOUNT(pairbackward_hole); break; } - posix_fadvise(second.fd(), e_second.begin(), e_second.size(), POSIX_FADV_WILLNEED); + readahead(second.fd(), e_second.begin(), e_second.size()); #else // This tends to repeatedly process extents that were recently processed. // We tend to catch duplicate blocks early since we scan them forwards. @@ -515,7 +515,7 @@ BeesRangePair::grow(shared_ptr ctx, bool constrained) BEESCOUNT(pairforward_hole); break; } - posix_fadvise(second.fd(), e_second.begin(), e_second.size(), POSIX_FADV_WILLNEED); + readahead(second.fd(), e_second.begin(), e_second.size()); } BEESCOUNT(pairforward_try);