[php-src] PR #16565: implement r/w locks to improve performance
| From: | withinboredom | Date: | Wed, 23 Oct 2024 21:34:54 +0000 |
| Subject: | [php-src] PR #16565: implement r/w locks to improve performance | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-29382@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/16565
Author: withinboredom
While investigating some performance issues with FrankenPHP, @AlliBalliBaba discovered that
environment access takes an exclusive lock before accessing the environment. This PR makes a small
ABI break to
tsrm_env_unlock and tsrm_env_lock to indicate whether the
environment will be modified. This will take a shared lock for reading (so that multiple threads can
read at once) and an exclusive lock on writing.
This change should increase performance for ZTS builds (especially those using modern frameworks
that make heavy use of environment variables): https://github.com/dunglas/frankenphp/pull/1080#discussion_r1796155640
increasing performance by ~2x under load for the litespeed SAPI.