-
Notifications
You must be signed in to change notification settings - Fork 420
perf: only import os environment variables once per worker thread #1080
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Leak should be fixed. I think caching the os environment is the expected default for worker mode. I can add it as optional to the Caddy config though |
|
I'm in favor of both adding this cache (without an option to disable it) to mimick the FPM behavior and merging #1086. Very good work again! |
|
Can we merge this one? |
|
I think we can probably merge this. Super-globals (or auto_globals) still have some weirdness about them that I'm trying to understand. Their |
|
Thank you! |
I noticed that php_import_environment_variables will lock and increasingly slow down the server as more environment variables are imported.
Since many frameworks will cache environment variables in production, the import often ends up being redundant. I think it would make sense to only import them once per thread, at least in worker mode.
Some open points:
Here is a graph showing that the server slows down with an increasing amount of environment variables .

When we load the environment from a
zvalthat's cached on the thread, the slowdown is much less significant:the env variables have ~40 characters each
Note that 10 threads is the 'ideal' amount of threads on my 20 core machine when PHP does minimal work