Skip to content

Commit 8edd909

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 50ccea3 commit 8edd909

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

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
@@ -2098,7 +2098,6 @@ zend_result php_module_startup(sapi_module_struct *sf, zend_module_entry *additi
20982098
zuf.getenv_function = sapi_getenv;
20992099
zuf.resolve_path_function = php_resolve_path_for_zend;
21002100
zend_startup(&zuf);
2101-
zend_reset_lc_ctype_locale();
21022101
zend_update_current_locale();
21032102

21042103
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)