-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Use __attribute__((assume())) in ZEND_ASSUME when available #13171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hmm, it seems this only starts behaving correctly from GCC 13+. We'll have to pin it for now. |
8b48851
to
36ea119
Compare
What was wrong with the old versions? |
I previously used autoconf to recognize whether the attribute was available. However, even though it's there in GCC 11/12 it seems not to work in various contexts, i.e. it failed to compile. It only works properly in GCC 13 for arbitrary expressions, as it's part of the C++23 specification (but works in C too). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I don't object.
Do you see any performance difference? (visible or callgrind)
@dstogov I only tried Valgrind, but did not come to any definitive conclusions. Some benchmarks were faster and some were marginally slower, but unfortunately the Symfony Demo is still flaky, so performance differences are easier to see over a longer period of time with many runs. |
36ea119
to
adee760
Compare
There is one more issue. GCC emits a warning when the attribute appears directly after a label. Prefixing it with Edit: Actually we need a do-while loop for single-statement contexts. Macros are hard. Here are the Valgrind results:
As expected, I messed up. My configure script passed unrelated
Hopefully the improvement Bob found is still legit, as Valgrind isn't always a good representation. |
adee760
to
952fc4a
Compare
|
I will investigate the generated assembly, but I'm guessing that for |
I must have done something wrong, I could not believe that either. So recompiled it and got something between 0 and 0.5% difference now. The generated assembly is a bit better though, like gcc allocating less stack space for a lot of frames now. |
Heh, you and me both 😅 Anyway, at least we can see a small improvement. Thanks for checking! |
On GCC, with this patch, I can see a reduction of assembly lines from 1134787 to 1132912 (-0.17%), and reduction of the sapi/cli/php binary size from 47974048 to 47897952 (-0.16%).
Prompted by #13159.
/cc @jorgsowa @dstogov