mirror of
				https://github.com/Zygo/bees.git
				synced 2025-10-31 18:20:34 +01:00 
			
		
		
		
	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 <bees@furryterror.org>
This commit is contained in:
		| @@ -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<off_t, pair<BeesHash, BeesAddress>> insert_map; | ||||
| 	set<off_t> noinsert_set; | ||||
|   | ||||
| @@ -386,8 +386,8 @@ BeesRangePair::grow(shared_ptr<BeesContext> 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<BeesContext> 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<BeesContext> 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); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user