Ticket #2810 (assigned)

Opened 4 years ago

easy to get pathological hash behavior when low-order bits don't change

Reported by: tim Assigned to: tim (accepted)
Priority: low Milestone:
Component: Core Version:
Severity: optimization Keywords:
Cc:

Description

This script takes 38 seconds or so in both zend php and phpoo, since we just bit-and numerical hash keys with a mask, so when the low-order bits don't change, they all end up in the same bucket.  Using the fnv-1a hash for numerical keys makes us take only 1.2 seconds, but at the cost of also taking 1.2 seconds when the low-order bits _do_ change, when  php takes only 0.6.  Since we can't afford to be slower, and this is a somewhat rare case, I'll leave this out for now.  But the code for the numerical hash is in php-hash-helper.c, should it ever come up.


<?php

$inc = 1024;
for ($i=0; $i<($inc * 100000); $i+=$inc) {
	$foo[$i] = "on";
}
for ($i=0; $i<($inc * 100000); $i+=$inc) {
	$baz[$i] =  $foo[$i];
}
print $i . "\n";
print count($foo) . "\n";

?>