From d7988e944727033f1ef9c62c7a0b323c4b614cae Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 17 Feb 2015 01:37:33 -0800 Subject: [PATCH] Made BloomFilterTitleHasLogs refresh odds linear to be smoother Change-Id: I25a4de8cf3537c9b3f27002e8bbb210322decec5 --- includes/cache/bloom/BloomFilters.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/includes/cache/bloom/BloomFilters.php b/includes/cache/bloom/BloomFilters.php index 9b710d7905..8017bac95c 100644 --- a/includes/cache/bloom/BloomFilters.php +++ b/includes/cache/bloom/BloomFilters.php @@ -26,8 +26,11 @@ class BloomFilterTitleHasLogs { public static function mergeAndCheck( BloomCache $bcache, $domain, $virtualKey, array $status ) { + $ttr = 5; // try to refresh before this many seconds $age = microtime( true ) - $status['asOfTime']; // seconds - $scopedLock = ( mt_rand( 1, (int)pow( 3, max( 0, 5 - $age ) ) ) == 1 ) + $chance = min( 1, $age / $ttr ); + + $scopedLock = ( mt_rand( 1, 1e9 ) <= 1e9 * $chance ) ? $bcache->getScopedLock( $virtualKey ) : false; -- 2.20.1