perf: hint the number of threads to TSRM (#655)

* perf: hint the number of threads to TSRM

* fix: PHP 8.2 compat
This commit is contained in:
Kévin Dunglas 2024-03-13 18:28:07 +01:00 committed by GitHub
parent 71661c45e2
commit b18a079eb9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -738,9 +738,16 @@ static void *manager_thread(void *arg) {
exit(EXIT_FAILURE);
}
int num_threads = *((int *)arg);
free(arg);
arg = NULL;
#ifdef ZTS
// TODO: use tsrm_startup() directly as we know the number of expected threads
#if (PHP_VERSION_ID >= 80300)
php_tsrm_startup_ex(num_threads);
#else
php_tsrm_startup();
#endif
/*tsrm_error_set(TSRM_ERROR_LEVEL_INFO, NULL);*/
#ifdef PHP_WIN32
ZEND_TSRMLS_CACHE_UPDATE();
@ -761,9 +768,7 @@ static void *manager_thread(void *arg) {
frankenphp_sapi_module.startup(&frankenphp_sapi_module);
threadpool thpool = thpool_init(*((int *)arg));
free(arg);
arg = NULL;
threadpool thpool = thpool_init(num_threads);
uintptr_t rh;
while ((rh = go_fetch_request())) {