In the process of looking at how projects handle ifunc support, I came across this in PHP's configure.ac: https://github.com/php/php-src/blob/edd72da03abc7dc1f2ae51825201488045f6ef37/configure.ac#L568-L569 dnl At least some versions of FreeBSD seem to have buggy ifunc support, see dnl bug #77284. Conservatively don't use ifuncs on FreeBSD. The referenced bug from late 2018: https://bugs.php.net/bug.php?id=77284 Suggestion there is it's fixed in FreeBSD 12, and the associated bugs in the thread point at a few other fixes that may or may not be relevant. Either way, with this disabled FreeBSD will be lacking SIMD versions of, er, whatever PHP has SIMD versions of, so perhaps some effort should be made to re-enable it and see what happens?
Thanks for the updates. I will try to enable this on next php83 release. However it will take some times to land into php81/php82 if it works on php83. It will not go into php80 at all anymore. And I will actually need some test results as I am no longer working for the company I used to where they used to heavy lift php works.
Testing with php81 I also run into: checking for __builtin_cpu_init... no This is also a prerequisite for ifunc support in PHP. Looking at the test in build/php.m4: return __builtin_cpu_init()? 1 : 0; That's an interesting thing to be doing with void __builtin_cpu_init(void)! I replaced with: __builtin_cpu_init();return 1; And now: ❯ ./php-ifunc addslash.php 10000000 iterations in 0.454 seconds ❯ ./php-no-ifunc addslash.php 10000000 iterations in 2.501 seconds ❯ ./php-ifunc base64.php 10000000 iterations in 0.580 seconds ❯ ./php-no-ifunc base64.php 10000000 iterations in 2.044 seconds
Created attachment 245119 [details] Patch for lang/php81
I think I didn't clarify in details. But at this moment this patch will not go into php81/php82. As around in 2 months we are going to change the default version to php82 from php81 and there are lots of work in between as we will have to go through exp-run and etc. I will consider adding these to php81/php82 sometimes around next year as this is still experimental and needs thorough testing before throwing it into the tiger den. So please update the patches for php83.
You were perfectly clear, the patch is purely informational - that's why I didn't flag it for maintainer-approval. I have a PR upstream for the __builtin_cpu_init check (https://github.com/php/php-src/issues/12273) so hopefully that bit shouldn't be needed for long.
Created attachment 245132 [details] Patch for lang/php83 Same patch for lang/php83 (minus a superfluous return statement). Passes the same very light tests with the same sort of performance improvements. I also tried it in Apache with a ZTS build successfully: mod_php81-8.1.23_2: addslashes: 10000000 iterations in 2.749 seconds base64: 10000000 iterations in 2.338 seconds mod_php83-8.3.0.r2_1: addslashes: 10000000 iterations in 0.557 seconds base64: 10000000 iterations in 0.637 seconds My two tiny PHP apps also seem to still work.
Thanks. Running build tests.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=13b9ae91576775f52d9ea7ebc026b690f0a743ca commit 13b9ae91576775f52d9ea7ebc026b690f0a743ca Author: Thomas Hurst <tom@hur.st> AuthorDate: 2023-09-23 11:11:12 +0000 Commit: Muhammad Moinur Rahman <bofh@FreeBSD.org> CommitDate: 2023-09-23 11:15:05 +0000 lang/php83: Reintroduce ifunc support SIMD functions were disabled prior to 12 and it was never chased upstream. However now it supports ifunc or it has improved. So let's test and see how well it works. There is an upstream PR: https://github.com/php/php-src/pull/12274 PR: 274011 lang/php83/Makefile | 1 + lang/php83/files/patch-build_php.m4 (new) | 11 +++++++++++ lang/php83/files/patch-configure.ac | 19 ++++++++++++++----- 3 files changed, 26 insertions(+), 5 deletions(-)
Let's test this and see how it goes. If it goes well I will introduce it into php81/php82 after this year.