Hey guys,
Although I'm senile and I don't remember 100%, I believe Ralf is
right and the slight difference must have slipped in when I used his
optimized version of the hash function. I don't think I meant to make
the change from xor to addition.
I suggest to leave it as-is as, as there seems to be really no
difference between the versions, and I doubt that on most CPUs xor
vs. addition take a different time to execute.
Ralf, thanks for your feedback.
Andi
At 10:29 AM 11/20/2005, Ralf S. Engelschall wrote:
On Sun, Nov 20, 2005, Stefan Esser wrote:
> I just realised, that between PHP4 and PHP5 we changed the hash function
> used within zend_hash.h from DJBX33X to DJBX33A. The diff is here =>
>
http://cvs.php.net/diff.php/ZendEngine2/zend_hash.h?ws=0&r1=1.57&r2=1.58&ty=u
>
> Does anyone remember the exact reason for that? Or was the change done
> by accident when the loops were unrolled? I have no idea if there is a
> big difference for our hashing needs, but I am just curious if we
> changed it because of benchmarks...
I don't know anything about the decisions within PHP development,
but the root reference for both are certainly my OSSP act sources:
http://cvs.ossp.org/getfile/ossp-pkg/act/act_hash_fct.c
There I've done in 2002 a comparison of mostly all known
(non-cryptography) hash functions which were in common use at this
time, including DJBX33A and DJBX33X. From my results (see the table
starting in the comment at line 80) you can see that both are more or
less equal, both in speed and distribution. The DJBX33A is the classical
one from DJB while DJBX33X is a revised version from him he used
later (but without any explanations by him or anybody else about the
advantages/disadvantages, although I think it is for just speed).
I guess Andi perhaps has just overlooked the small subtle difference
("+" operation for DJBX33A and "^" for DJBX33X), because as his commit
log for PHP explains, his intention was to provide an optimized version
(via the loop unrolling) plus my explanation about this hash function.
So, the conversion from DJBX33A to DJBX33X was perhaps just by accident.
But it doesn't really hurt: as I said, DJBX33X and DJBX33A are more or
less equal in quality and speed. DJBX33X is even slightly faster on most
processors so choosing DJBX33X is fully ok. At least because of this I
personally also prefer DJBX33X over DJBX33A. No need to change anything
at least... ;-)
Ralf S. Engelschall
[EMAIL PROTECTED]
www.engelschall.com
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php