Bug #70621 [NEW]: gmp much faster with old VC6-builds
From: anna1008 at t-online dot de
Operating system: Windows 7 Home Premium 32bit SP1
PHP version: 5.6.14
Package: Performance problem
Bug Type: Bug
Bug description:gmp much faster with old VC6-builds
Description:
------------
I've experienced slow performance of the recent VC11 builds compared to
the old VC6 builds when running gmp_*-functions on big integers. My test
script factorizes the first 1,000 integers >= 2^16, 2^24 and 2^32 with
trial division. All tests were executed in CLI and shared the same
php.ini (default production-ini just with gmp extension).
Test script:
---------------
<?php
for ($e = 16; $e <= 32; $e+=8) { # 16, 24, 32
$n = gmp_pow(2, $e); # n := 2^e
$t0 = microtime(true);
for ($i = 0; $i < 1000; $i++) {
trialdiv($n);
$n = gmp_add($n, 1); # n++
}
$dt = microtime(true) - $t0;
echo phpversion() . " e=$e dt=$dt sec\n";
}
function trialdiv($n) {
if (gmp_prob_prime($n) != 0) return; # n is probably or surely prime
$p = gmp_init(2); # start with prime 2
for (;;) {
if (gmp_cmp(gmp_mul($p, $p), $n) > 0) return; # p^2 > n, trial
division complete
while (gmp_cmp(gmp_mod($n, $p), 0) == 0) $n = gmp_divexact($n, $p); #
while p divides n do n:= n/p
$p = gmp_nextprime($p); # try next prime
}
}
?>
Expected result:
----------------
I've expected marginal performance differences between the old
VC6-builds and the recent VC11-builds.
Actual result:
--------------
my results with php-5.2.14-Win32-VC6-x86:
5.2.14 e=16 dt=0.046411037445068 sec
5.2.14 e=24 dt=0.27050685882568 sec
5.2.14 e=32 dt=2.0851769447327 sec
my results with php-5.6.14-Win32-VC11-x86:
5.6.14 e=16 dt=0.046800136566162 sec
5.6.14 e=24 dt=0.51480078697205 sec
5.6.14 e=32 dt=8.533215045929 sec
summary:
At 2^16 the differences are marginal.
At 2^24 the VC6-build is 1.9 times faster
At 2^32 the VC6-build is 4.1 times faster.
--
Edit bug report at https://bugs.php.net/bug.php?id=70621&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70621&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70621&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70621&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=70621&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=70621&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=70621&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=70621&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=70621&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=70621&r=support
Expected behavior: https://bugs.php.net/fix.php?id=70621&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=70621&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=70621&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=70621&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70621&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=70621&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=70621&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=70621&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70621&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=70621&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=70621&r=mysqlcfg
Thread (5 messages)
- anna1008 at t-online dot de