From: Aaron Schulz Date: Tue, 17 Feb 2015 09:37:33 +0000 (-0800) Subject: Made BloomFilterTitleHasLogs refresh odds linear to be smoother X-Git-Tag: 1.31.0-rc.0~12361^2 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=d7988e944727033f1ef9c62c7a0b323c4b614cae;p=lhc%2Fweb%2Fwiklou.git Made BloomFilterTitleHasLogs refresh odds linear to be smoother Change-Id: I25a4de8cf3537c9b3f27002e8bbb210322decec5 --- 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;