Req #73277 [Com]: crc32() not using CPU capabilities

From: Date: Wed, 03 Mar 2021 13:44:09 +0000
Subject: Req #73277 [Com]: crc32() not using CPU capabilities
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-232511@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73277&edit=1 ID: 73277 Comment by: rtrtrtrtrt at dfdfdfdf dot dfd Reported by: spam2 at rhsoft dot net Summary: crc32() not using CPU capabilities Status: Open Type: Feature/Change Request Package: Performance problem Operating System: Linux PHP Version: 7.0.11 Block user comment: N Private report: N New Comment: 7.4.15-sandybridge-fc33 i gave up PHP8 a while ago since it don't build with PGO here (segfault in mod_php as soon as it's loaded) and the nonsense of deprecate zip-functions without 1:1 replacement as well as https://bugs.php.net/bug.php?id=79350 don't make it easier either in an environment treating notices/warnings as fatal errors Previous Comments: ------------------------------------------------------------------------ [2021-03-03 13:37:58] cmb@php.net Thanks for checking! I presume this has been measures with PHP 8.0? ------------------------------------------------------------------------ [2021-03-03 13:15:25] rtrtrtrtrt at dfdfdfdf dot dfd md4: 0.18111 md5: 0.28866 sha1: 0.40015 crc32: 0.47416 still the slowest ------------------------------------------------------------------------ [2021-03-03 13:07:43] cmb@php.net The crc32 implementation has been improved since PHP 7.0.11. Is it good for you now? ------------------------------------------------------------------------ [2016-10-09 16:45:10] spam2 at rhsoft dot net Description: ------------ for short messages crc32 seems to be the fastest way but for long messages like a whole page content for a ETAG-HTTP-Header it's the slowest md5: 0.48954606056213 sha1: 0.57872104644775 crc32: 0.64182901382446 that should not be the case on modern Intel CPUs like SnadyBrdige or newer which support a accelerated instruction Test script: --------------- $test_content = file_get_contents('global.inc.php', true); echo '<strong>md5: </strong>' . md5($test_content) . MY_LE; $profiler->reset(); for($x=1;$x<5000;$x++) { $rw = md5($test_content); } echo $profiler->get() . '<br /><br />' . MY_LE; echo '<strong>sha1: </strong>' . sha1($test_content) . MY_LE; $profiler->reset(); for($x=1;$x<5000;$x++) { $rw = sha1($test_content); } echo $profiler->get() . '<br /><br />' . MY_LE; echo '<strong>crc32: </strong>' . abs(crc32($test_content)) . MY_LE; $profiler->reset(); for($x=1;$x<5000;$x++) { $rw = crc32($test_content); } echo $profiler->get() . '<br /><br />' . MY_LE; ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=73277&edit=1

« previous php.bugs (#232511) next »