Bug #70621 [Opn]: gmp much faster with old VC6-builds

From: Date: Sat, 03 Oct 2015 07:57:01 +0000
Subject: Bug #70621 [Opn]: gmp much faster with old VC6-builds
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196361@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70621&edit=1 ID: 70621 Updated by: nikic@php.net Reported by: anna1008 at t-online dot de Summary: gmp much faster with old VC6-builds Status: Open Type: Bug Package: Performance problem Operating System: Windows 7 Home Premium 32bit SP1 PHP Version: 5.6.14 Block user comment: N Private report: N New Comment: I can confirm that there is a large GMP slowdown between PHP 5.3 and 5.4, at least on Windows. I kindof doubt this is related to VC versions though. Previous Comments: ------------------------------------------------------------------------ [2015-10-02 10:23:18] anna1008 at t-online dot de 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 this bug report at https://bugs.php.net/bug.php?id=70621&edit=1

« previous php.bugs (#196361) next »