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

From: Date: Sat, 03 Oct 2015 11:58:07 +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-196364@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 User updated by: anna1008 at t-online dot de 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: @nikic: Yes, it's better to say: "the 5.2-build is much faster than the following builds". I didn't want to relate it to the compiler or anything else. But I wouldn't exclude the compiler as a reason, when I consider that I need to install a Microsoft "Visual C++ Redistributable" to run the builds... Here are more results with all available lastest 5.x-builds. When I look at the php-gmp-changelog I can only see one big change: the change from php resource to php object in 5.6 (other changes are mostly adding of missing gmp-functions). But the slowdown already began with 5.3 and became real big with 5.4. my results with php-5.2.17-Win32-VC6-x86: 5.2.17 e=16 dt=0.047152042388916 sec 5.2.17 e=24 dt=0.27974796295166 sec 5.2.17 e=32 dt=2.1529459953308 sec my results with php-5.3.29-Win32-VC9-x86: 5.3.29 e=16 dt=0.060003995895386 sec 5.3.29 e=24 dt=0.39502215385437 sec 5.3.29 e=32 dt=3.2831878662109 sec my results with php-5.4.45-Win32-VC9-x86: 5.4.45 e=16 dt=0.052003145217896 sec 5.4.45 e=24 dt=0.58403301239014 sec 5.4.45 e=32 dt=9.3995378017426 sec my results with php-5.5.30-Win32-VC11-x86: 5.5.30 e=16 dt=0.051002025604248 sec 5.5.30 e=24 dt=0.55403208732605 sec 5.5.30 e=32 dt=8.8055038452148 sec my results with php-5.6.14-Win32-VC11-x86: 5.6.14 e=16 dt=0.046002864837646 sec 5.6.14 e=24 dt=0.51803016662598 sec 5.6.14 e=32 dt=8.6654949188232 sec . Previous Comments: ------------------------------------------------------------------------ [2015-10-03 07:57:01] nikic@php.net 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. ------------------------------------------------------------------------ [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 (#196364) next »