From: Aaron Schulz Date: Mon, 22 Apr 2013 20:47:52 +0000 (-0700) Subject: Bumped RING_SIZE to use 28 bits to improve weight accuracy a bit. X-Git-Tag: 1.31.0-rc.0~19910 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=aaee02008896f5754246e456c9c595876aa04bcd;p=lhc%2Fweb%2Fwiklou.git Bumped RING_SIZE to use 28 bits to improve weight accuracy a bit. Change-Id: I4dbecd292fd404e43ed296dd37892db113fa1026 --- diff --git a/includes/HashRing.php b/includes/HashRing.php index 10a3c9c161..227a287de8 100644 --- a/includes/HashRing.php +++ b/includes/HashRing.php @@ -30,7 +30,7 @@ class HashRing { /** @var Array (location => (start, end)) */ protected $ring = array(); - const RING_SIZE = 16777216; // 2^24 + const RING_SIZE = 268435456; // 2^28 /** * @param array $map (location => weight) @@ -86,7 +86,7 @@ class HashRing { public function getLocations( $item, $limit ) { $locations = array(); $primaryLocation = null; - $spot = hexdec( substr( sha1( $item ), 0, 6 ) ); // first 24 bits + $spot = hexdec( substr( sha1( $item ), 0, 7 ) ); // first 28 bits foreach ( $this->ring as $location => $range ) { if ( count( $locations ) >= $limit ) { break;