[php-src] PR #23227: perf: move EG() and CG() in ZTS builds into __thread storage
| From: | henderkes | Date: | Wed, 12 Aug 2026 12:12:05 +0000 |
| Subject: | [php-src] PR #23227: perf: move EG() and CG() in ZTS builds into __thread storage | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-37794@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/23227
Author: henderkes
replay of #22231
Moves EG and CG into __thread storage after all. We first moved them into constant offsets (#22287)
from *_tsrm_ls_cache, but I couldn't find a way to stop gcc or clang from reloading
_tsrm_ls_cache base pointer between function calls, leading to an extra pointer load once per
function.
This eliminates the pointer load, making the access sequence to EG/CG just a single mov (x64) / mrs
+ add + ldr (aarch64) under local-exec. initial-exec likewise loses the pointer load so 3 -> 2
instructions (x64).
cc @arnaud-lb
What I'm adding here to counter the global-dynamic fallback slowdown is the option to
explicitly opt-in to initial-exec, under the knowledge that host programs loading it will need to
increase the static tls surplus. This is not an issue for package providers.
PS: Actually figured out that the explicit model choice doesn't happen for musl, not sure about
IE (static tls surplus on musl?), but LE should work just fine. That's for another PR though.