-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] Optimization of resolveEnvPlaceholders #44876
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
[DependencyInjection] Optimization of resolveEnvPlaceholders #44876
Conversation
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
Hey! I think @VincentLanglet has recently worked with this code. Maybe they can help review this? Cheers! Carsonbot |
Would it be possible to have Blackfire traces before/after your optimization? |
@Kocal only xhprof |
Great @sveneld, it would be interesting to see the before and after profiles |
https://drive.google.com/drive/folders/1GoWngjjwXA6TQrGYix7xVk-LSLl3ijvp?usp=sharing Main difference in Symfony\Component\DependencyInjection\ContainerBuilder::resolveEnvPlaceholders==>stripos it calls less |
Not at all, I asked this question in anticipation, in order to save time for the core team 😛 |
@nicolas-grekas can you look? |
Thank you @sveneld. |
@nicolas-grekas when new tag with this code appear in 5.4 version? |
Absolutely. We merge older branches into newer ones from time to time and before releases. |
…veneld) This PR was merged into the 6.2 branch. Discussion ---------- [DependencyInjection] Container building optimization | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | no | New feature? | no | Deprecations? | no | License | MIT When you have to much env variables and many services in your container, container compilаtion can take much time due to the function stripos which is called much time. It happens because method freezeAfterProcessing try to find env placeholders in config, but make it in two foreach. So i offer to get all possible placeholders with preg_match_all and do not use stripos for each placeholed. Same situation with method resolveEnvPlaceholders. But in this method we should left stripos for hard cases when in value could be something like this 'env_1418b707a69b8575_const_HOST_74bcc04c4799f2ca10fb754fe5581c89env_1418b707a69b8575_const_CORE_URL_91ef68034c1e9e8b58c13725d3bafdc0' In my project it helps me to save 40 seconds in container building. Related to my previous fix #44876 Commits ------- c886e2c [DependencyInjection] Container building optimization
When you have to much env variables and many services in your container, container compilаtion can take much time due to the function stripos which is called much time.
Look at the bottom of picture https://i2.piccy.info/i9/cdc413af9aecce8f7ed5ca0fe69b6c7c/1640950765/149173/1453384/6833Screenshot_from_2021_12_31_13_38_20.png
It happens because function resolveEnvPlaceholders try to find env placeholders in any value, even when there is no possible env in string.
So i offer to check value on strings env_ or env( and if they are present than look for placeholders.
In my project it helps me to save 10 seconds in container building.