PHP performing worse than stock Arch and ALHP

Hi all,

not sure where to report if at all or if anyone cares for that matter, so I’ll just leave it here.

I’ve ran the bench.php script that is in the PKGBUILDS repo and was quite surprised to see Cachys package be this slow.

PHP...................................... 8.3.8 |.................... 8.3.8 |.................... 8.3.8 |.................... 8.3.8 |.................... 8.3.8
Platform................................. Linux |.................... Linux |.................... Linux |.................... Linux |.................... Linux
Arch.................................... x86_64 |................... x86_64 |................... x86_64 |................... x86_64 |................... x86_64
Server.............................. Arch_Linux |.................. ALHP_V3 |.................. ALHP_V4 |................. Cachy_V3 |................. Cachy_V4
Max memory usage.......................... 128M |..................... 128M |..................... 128M |..................... 128M |..................... 128M
OPCache status......................... enabled |.................. enabled |.................. enabled |.................. enabled |.................. enabled
OPCache JIT............................ enabled |.................. enabled |.................. enabled |.................. enabled |.................. enabled
PCRE JIT............................... enabled |.................. enabled |.................. enabled |.................. enabled |.................. enabled
XDebug extension...................... disabled |................. disabled |................. disabled |................. disabled |................. disabled
Difficulty multiplier...................... 16x |...................... 16x |...................... 16x |...................... 16x |...................... 16x
Started at............. 28/06/2024 20:11:09.336 |.. 28/06/2024 20:12:13.012 |.. 28/06/2024 20:14:44.001 |.. 28/06/2024 20:15:48.150 |.. 28/06/2024 20:17:31.621
---------------------------------------------------------------------------------------------------------------------------------------------------------------
math.................................. 1.4561 s |................. 1.3551 s.|................. 1.4556 s |................. 1.5123 s |................. 1.5110 s
loops................................. 0.5638 s |................. 0.5651 s.|................. 0.5674 s |................. 0.5640 s |................. 0.5624 s
ifelse................................ 0.2443 s |................. 0.2460 s.|................. 0.2483 s |................. 0.2448 s |................. 0.2440 s
switch................................ 0.2463 s |................. 0.2482 s.|................. 0.2494 s |................. 0.2457 s |................. 0.2453 s
string................................ 3.2887 s |................. 3.3984 s.|................. 3.3471 s |................. 5.4579 s |................. 5.3480 s
array................................. 5.0307 s |................. 5.0584 s.|................. 5.0771 s |................. 8.0283 s |................. 8.0689 s
regex................................. 2.4944 s |................. 2.0063 s.|................. 1.9392 s |................. 2.4163 s |................. 2.4144 s
is_{type}............................. 0.4561 s |................. 0.4562 s.|................. 0.4544 s |................. 0.6962 s |................. 0.5886 s
hash.................................. 1.4312 s |................. 1.3390 s.|................. 1.4064 s |................. 1.5380 s |................. 1.5347 s
json.................................. 2.4488 s |................. 2.4707 s.|................. 2.4419 s |................. 2.9082 s |................. 2.9518 s
---------------------------------------------------------------------------------------------------------------------------------------------------------------
Total time........................... 17.6604 s |................ 17.1435 s.|................ 17.1868 s |................ 23.6117 s |................ 23.4691 s
Peak memory usage........................ 2 MiB |.................... 2 MiB.|.................... 2 MiB |.................... 2 MiB |.................... 2 MiB

This is the best of 5 runs on an AMD Ryzen 7 7840U.

It seems that whatever is done to further optimize the package actually does the opposite.

Hi,

I don’t know, what is up with your system. Could it be, that you somehow modified the config?

Ive tested it with “PHPBench” and the result is around twice as fast as stock. This is also visible by a third party benchmark:

No v3 or v4 → archlinux package

Ive also rebenched it fastly, and it is looking fine:

I know, that the stock package does not enable opcache or equal, so we should do some retesting as soon time is available.

Basically, as you see in the PKGBUILD it does use the official make prof-gen way, to generate a profile, aditionally it runs the above php bench, to generate on top of that the profiles.

Indeed, the PGO’d version is a bit slower, then the not PGO’d version.
Ive compared both with the same config

Ive pushed a not PGO’d version to znver4 - please try.

That was indeed it, thanks for the quick fix!

PHP.............................................. 8.3.8
Platform......................................... Linux
Arch............................................ x86_64
Server.................................... php-cachy-v4
Max memory usage.................................. 128M
OPCache status................................. enabled
OPCache JIT.................................... enabled
PCRE JIT....................................... enabled
XDebug extension.............................. disabled
Difficulty multiplier.............................. 16x
Started at..................... 29/06/2024 07:58:26.991
-------------------------------------------------------
math.......................................... 1.2780 s
loops......................................... 0.5657 s
ifelse........................................ 0.2463 s
switch........................................ 0.2451 s
string........................................ 3.0748 s
array......................................... 4.8092 s
regex......................................... 1.8967 s
is_{type}..................................... 0.4435 s
hash.......................................... 1.3913 s
json.......................................... 2.2598 s
-------------------------------------------------------
Total time................................... 16.2104 s
Peak memory usage................................ 2 MiB

Fyi: I’ve also tried the script on Clear Linux:

-------------------------------------------------------
|       PHP BENCHMARK SCRIPT v.2.0 by @SergiX44       |
-------------------------------------------------------
PHP.............................................. 8.3.8
Platform......................................... Linux
Arch............................................ x86_64
Server.................................. php-clearlinux
Max memory usage.................................. 128M
OPCache status................................. enabled
OPCache JIT.................................... enabled
PCRE JIT...................................... disabled
XDebug extension.............................. disabled
Difficulty multiplier.............................. 16x
Started at..................... 29/06/2024 07:27:57.832
-------------------------------------------------------
math.......................................... 1.1477 s
loops......................................... 0.2692 s
ifelse........................................ 0.2107 s
switch........................................ 0.2203 s
string........................................ 3.1118 s
array......................................... 5.0072 s
regex......................................... 7.4661 s
is_{type}..................................... 0.4044 s
hash.......................................... 1.3502 s
json.......................................... 2.3368 s
-------------------------------------------------------
Total time................................... 21.5244 s
Peak memory usage................................ 2 MiB

Unfortunately I could not figure out how to enable PCRE JIT on there, otherwise it would be the fastest.
Loops being twice as fast is what caught my eye I’d really like to know how they did that.

Glad that it got solved, even tough its kinda weird that the official PGO way, does reduce the performance.
Ill also push it to other distros.

If you are deeply into php - feel free to patch the default config further.