Rationale for using MD5 hash
authorTim Starling <tstarling@wikimedia.org>
Wed, 19 Sep 2012 05:25:31 +0000 (15:25 +1000)
committerAlexandre Emsenhuber <ialex.wiki@gmail.com>
Wed, 19 Sep 2012 16:35:42 +0000 (18:35 +0200)
Just documenting some benchmark work I did.

Change-Id: Ic24edc5b857e06a8bfe83d70f2da0d7f4690c6af

includes/objectcache/RedisBagOStuff.php

index c5966cd..d5de044 100644 (file)
@@ -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 );