-
Notifications
You must be signed in to change notification settings - Fork 11.6k
[5.2] [WIP] Fixing dotenv loading #13391
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
We don't want to load anything if w have cached config for performance reasons. |
Only ever read env variables from inside config files. |
|
That is not allowed anymore for performance reasons, and it would be a bad practice anyway. |
Yes, it is a bottleneck. We found a 25% throughput increase on the out of the box app when applying these optimizations when prepping for the 5.2 release. |
I don't agree that there exists an issue. Sorry. |
I meant performances of dotenv in particular, amongst the sum of config files + dotenv. |
Yes, config caching with dotenv vs config cahing without dotenv was the 25% different. The change was actually larger than having config caching enabled! |
Summary: dotenv is REALLY slow because it means we have to do disk IO and lots of CPU time. PHP already has internal optimization for loading compiled php files into memory, so requiring php files is inexpensive, That's also why we made the services.json -> services.php change. |
Dotenv also has concurrency bugs, and is not suitable for production use. It should only be used to initialize config files like we're using it for in L5.2 really. For that kind of use it's safe. |
Whereas As showed in #13351, this is a limitation. Also, this is inconsistent and could lead to other bugs. |
Thanks for the above explanations concerning dotenv. |
No plans to improve this? It's complicated because env and config loading depend on each other… |
Follow-up to #13351. Please note this is very much a WIP and may have important caveats.
Important: we would lose
app.env
config. But that may be a good thing, things get mixed up because of this setting. Better useapp()->environment()
.