From: viper7 at viper-7 dot com
Operating system: Any
PHP version: 5.2.9
PHP Bug Type: Performance problem
Bug description: array_diff takes over 3000 times longer than php 5.2.0
Description:
------------
This bug was reported in ##php on freenode, and after some thorough
testing on multiple machines we determined it must be an engine bug.
array_diff on two large arrays of md5 hashes (600,000 elements each) takes
approximately 4 seconds on a fast server in PHP 5.2.4 and below (confirmed
with PHP 5.2.0), but over 4 hours (!) on PHP 5.2.6 and greater (confirmed
with PHP 5.2.9 and PHP 5.3.0 beta2)
Reproduce code:
---------------
<?php
$i=0; $j=500000;
while($i < 600000) {
$i++; $j++;
$data1[] = md5($i);
$data2[] = md5($j);
}
$time = microtime(true);
echo "Starting array_diff\n";
$data_diff1 = array_diff($data1, $data2);
$time = microtime(true) - $time;
echo 'array_diff() took ' . number_format($time, 3) . ' seconds and
returned ' . count($data_diff1) . " entries\n";
?>
Expected result:
----------------
Starting array_diff
array_diff() took 3.778 seconds and returned 500000 entries
Actual result:
--------------
Starting array_diff
array_diff() took 14826.278 seconds and returned 500000 entries
--
Edit bug report at http://bugs.php.net/?id=47643&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=47643&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=47643&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=47643&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=47643&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=47643&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=47643&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=47643&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=47643&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=47643&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=47643&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=47643&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=47643&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=47643&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=47643&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47643&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=47643&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=47643&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=47643&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=47643&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=47643&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=47643&r=mysqlcfg