Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 90b9484

Browse files
committed
Fix GH-12778: Windows IIS FastCGI Spin-Up Performance Slowdown
The issue isn't limited to Windows only, I can also see the slowdown on my Linux machine. The cause of the slowdown is 26e4244. In that commit a locale reset routine was implemented that gets called on startup. The fix from that commit is only necessary when using readline functionality, there are three places that is used: - phpdbg - with readline_cli - readline() php function So we make sure we only reset the locale when one of these is used, preventing the overhead on normal website-serving use-cases.
1 parent 37a1e19 commit 90b9484

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed

‎UPGRADING.INTERNALS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,11 @@ PHP 8.4 INTERNALS UPGRADE NOTES
6363
========================
6464
5. SAPI changes
6565
========================
66+
67+
* The LC_CTYPE locale is no longer overridden at module startup to C.UTF-8.
68+
This was originally introduced to fix an issue with UTF-8 characters when
69+
libedit was used for providing the readline functionality. The new fix now
70+
delays the locale reset until the readline functionality is actually used.
71+
SAPIs relying on this behaviour must manually call zend_reset_lc_ctype_locale().
72+
This change is done to fix a performance regression.
73+
See https://github.com/php/php-src/pull/12784.

‎ext/readline/readline.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,15 @@ PHP_MINFO_FUNCTION(readline)
115115

116116
/* }}} */
117117

118+
static void php_readline_fix_locale() {
119+
/* Yes, this variable is process-wide, but so is the locale setting. */
120+
static bool locale_fixed = false;
121+
if (!locale_fixed) {
122+
locale_fixed = true;
123+
zend_reset_lc_ctype_locale();
124+
}
125+
}
126+
118127
/* {{{ Reads a line */
119128
PHP_FUNCTION(readline)
120129
{
@@ -126,6 +135,8 @@ PHP_FUNCTION(readline)
126135
RETURN_THROWS();
127136
}
128137

138+
php_readline_fix_locale();
139+
129140
result = readline(prompt);
130141

131142
if (! result) {

‎ext/readline/readline_cli.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,8 @@ static int readline_shell_run(void) /* {{{ */
634634
#endif
635635
read_history(history_file);
636636

637+
zend_reset_lc_ctype_locale();
638+
637639
EG(exit_status) = 0;
638640
while ((line = readline(ZSTR_VAL(prompt))) != NULL) {
639641
if (strcmp(line, "exit") == 0 || strcmp(line, "quit") == 0) {

‎main/main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2104,7 +2104,6 @@ zend_result php_module_startup(sapi_module_struct *sf, zend_module_entry *additi
21042104
zuf.getenv_function = sapi_getenv;
21052105
zuf.resolve_path_function = php_resolve_path_for_zend;
21062106
zend_startup(&zuf);
2107-
zend_reset_lc_ctype_locale();
21082107
zend_update_current_locale();
21092108

21102109
zend_observer_startup();

‎sapi/phpdbg/phpdbg.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,8 @@ int main(int argc, char **argv) /* {{{ */
13561356
PHPDBG_G(flags) = flags;
13571357

13581358
if (phpdbg->startup(phpdbg) == SUCCESS) {
1359+
zend_reset_lc_ctype_locale();
1360+
13591361
zend_mm_heap *mm_heap;
13601362
#ifdef _WIN32
13611363
EXCEPTION_POINTERS *xp;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /