From 6a1a1698a571f0c3a70e49e28fbb720f156e1732 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Wed, 19 Sep 2012 15:25:31 +1000 Subject: [PATCH] Rationale for using MD5 hash Just documenting some benchmark work I did. Change-Id: Ic24edc5b857e06a8bfe83d70f2da0d7f4690c6af --- includes/objectcache/RedisBagOStuff.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/includes/objectcache/RedisBagOStuff.php b/includes/objectcache/RedisBagOStuff.php index c5966cdb06..d5de044607 100644 --- a/includes/objectcache/RedisBagOStuff.php +++ b/includes/objectcache/RedisBagOStuff.php @@ -289,6 +289,12 @@ class RedisBagOStuff extends BagOStuff { $candidates = $this->servers; } else { // Use consistent hashing + // + // Note: Benchmarking on PHP 5.3 and 5.4 indicates that for small + // strings, md5() is only 10% slower than hash('joaat',...) etc., + // since the function call overhead dominates. So there's not much + // justification for breaking compatibility with installations + // compiled with ./configure --disable-hash. $hashes = array(); foreach ( $this->servers as $server ) { $hashes[$server] = md5( $server . '/' . $key ); -- 2.20.1