dépôts
/
lhc
/
web
/
wiklou.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
ae698e8
)
Made BloomFilterTitleHasLogs refresh odds linear to be smoother
author
Aaron Schulz
<aschulz@wikimedia.org>
Tue, 17 Feb 2015 09:37:33 +0000
(
01:37
-0800)
committer
Aaron Schulz
<aschulz@wikimedia.org>
Tue, 17 Feb 2015 09:37:33 +0000
(
01:37
-0800)
Change-Id: I25a4de8cf3537c9b3f27002e8bbb210322decec5
includes/cache/bloom/BloomFilters.php
patch
|
blob
|
history
diff --git
a/includes/cache/bloom/BloomFilters.php
b/includes/cache/bloom/BloomFilters.php
index
9b710d7
..
8017bac
100644
(file)
--- 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;