-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[performance] Symfony Kernel::boot() in dev mode on Alpine #35009
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
Comments
Yes, I explained why in symfony/recipes#705 (comment)
I confirm this one, it shouldn't be that hard. |
I'm transferring this issue to the symfony repo, as that's not specifically about recipes. |
About my suggestion to split single glob-with-braces, here is the description from the gnu doc: |
I tries with this implementation, and I get a stunning optimization of -212ms... (-64%) https://blackfire.io/profiles/compare/3ff797c4-a931-4f18-8b4e-a57982d3d2cd/graph |
β¦ available (nicolas-grekas) This PR was merged into the 4.4 branch. Discussion ---------- [Config] fix perf of glob discovery when GLOB_BRACE is not available | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | Fix #35009 | License | MIT | Doc PR | - This PR implements a fast fallback implementation of GLOB_BRACE for musl-based libc, as found on Alpine. It is *not* a feature-complete fallback implementation. Implementing one would be [much more involving](https://github.com/zendframework/zend-stdlib/blob/master/src/Glob.php). But the provided implementation is good enough in practice IMHO, and the slow path is still used when not-covered glob patterns are used. Here is the comparison:   Commits ------- 8af6d86 [Config] improve perf of glob discovery when GLOB_BRACE is not available
Thanks a lot @nicolas-grekas! |
@nicolas-grekas I think your fix broke the discovery of package configurations. If I apply your changes from (d7a0679) I get the following error:
If I remove the changes everything works fine. |
Can you please provide a reproducer? |
@nicolas-grekas Sorry, can't provide atm as the project we are working on is private and I am currently on a vacation. The package that errors is https://packagist.org/packages/overblog/dataloader-bundle We have the full configuration file set up with the defaults key as well. We are running our app with Docker: The error I will try to put something as POC these days, but in the meantime I think thats enough info to reproduce. |
@Sh1d0w I am able to reproduce the error, but it looks unrelated to this change. I still have the error with v4.4.1.
is this the only change you're doing or are there any others, like updating the bundle also? |
@nicolas-grekas I've upgraded from Symfony 4.3 to 4.4 . The bundle that errors is using the same version v0.4.2 and I did not update its version. After the update to Symfony 4.4 I tested the app and it worked fine. Then tried to apply the change from your commit as I was keen to try it out before it was published, and I got this error. I've removed the changes to the GlobResource everything works fine. Just to be clear if I revert to Symfony 4.3 where everything is working ok as well, and apply the same changes to GlobResource I get the same error. |
Can you share the output of print_r($paths) just before this line, which exists in both versions? |
@nicolas-grekas Actually your fix is working fine, the problem was on my end! Really sorry for the spam and thanks for the great fix :) |
@Sh1d0w good news. Can you share the perf improvement on your side? It's very impressive on my project but we miss other feedback. |
Sure, it resulted approximately 50% reduction in load times, which is more than great (previously ~700ms, after the fix ~300 ms) |
@Sh1d0w wooot! |
@nicolas-grekas Will this fix be back ported and released for older versions of Symfony as a patch, or will be available only for 4.4 and above? |
@Sh1d0w that's going to be for 4.4 and up only. One more reason to upgrade asap :) |
This is a follow-up of this discussion.
Alpine is the default docker linux base distribution. It's widely used. It's based on musl libc, and so, it's quite different of traditional linux distribution as Debian. One the difference is that glob does not handle
GLOB_BRACE
.I knew about it from an old issue on composer that we already experienced.
On a big project, we had quite castrophous boot time, and I finally checked on it.
The first thing is that
Iterator/SortableIterator.php/44-46
cost an enormous amout of time and is called 22k time.Searching why, It seems that we never enter is the optimized path here
symfony/src/Symfony/Component/Config/Resource/GlobResource.php
Line 102 in 8ffdef2
I had that in
Kernel::configureContainer
:and in
services.yaml
:As I don't have
GLOB_BRACE
and every pattern given contains a brace, it always fallback on thesymfony/finder
implementation which is wayyy slower.By removing the
/**/*
, and only searching intoyaml
extension, I expect to be in the fast path. But the brackets on{packages}
and{services}
prevents it. By removing them it goes into the fast path. And gives a clear boost.I didn't see any drwabacks (and I have a very extensive tests suites).
Rest the case with multiple option separated by comma in brackets, that stills cost a lot.
I'm absolutly thinks this is a serious issue, but I'm not sure of what todo with it, hance the absence of PR.
symfony/finder
one. @nicolas-grekas purpose to "we could have some logic that splits a single glob-with-braces into several of them" Simplify the default KernelΒ recipes#705 (comment)The text was updated successfully, but these errors were encountered: