-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI] dump factory files as classes #36193
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
97d12a9
to
eb54c88
Compare
c14f919
to
5f6bff5
Compare
5f6bff5
to
cedb5cd
Compare
@@ -142,6 +142,10 @@ public function registerContainerConfiguration(LoaderInterface $loader) | |||
} | |||
|
|||
$container->setAlias(static::class, 'kernel')->setPublic(true); | |||
|
|||
if (!$container->hasParameter('container.dumper.inline_factories')) { | |||
$container->setParameter('container.dumper.inline_factories', false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't it be better to default container.dumper.inline_factories
to false when the parameter is not given? you changed this to true in https://github.com/symfony/symfony/pull/34872/files#diff-f7b23d463cba27ac5e4cb677f2be7623R154. so just reverting this would make the default behavior as wanted or?
…ault (nicolas-grekas) This PR was merged into the 5.1-dev branch. Discussion ---------- Revert to container.dumper.inline_factories=false by default | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - As spotted by @Tobion in #36193 (review) Commits ------- 2b6f1e9 Revert to container.dumper.inline_factories=false by default
…rvices (nicolas-grekas) This PR was merged into the 5.1 branch. Discussion ---------- [DI] fix minor perf regression when creating non-shared services | Q | A | ------------- | --- | Branch? | 5.1 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #37401 | License | MIT | Doc PR | - This PR restores some dumped code that was too aggressively removed in #36193. Commits ------- 75e2ee1 [DI] fix minor perf regression when creating non-shared services
This PR is a performance improvement when using
bin/console
on the command line.Once upon a time, we advised setting
container.dumper.inline_factories
tofalse
so that the container could be chunked into many files. More recently, we turned this setting back totrue
in order to optimize for preloading. But this madebin/console
back to slow: since the CLI cannot have opcache, PHP has to parse this potentially big file all the time. Previous data already showed this can grow big.This PR fixes the issue by generating many files again. But instead of generating the inline code within each file, we now wrap this code inside a class. Then we list this class for preloading.
This way, we have the best of both worlds: a
bin/console
that scales no matter the size of the app and top perf when using preloading (I benched a small hello world before/after the patch with preloading enabled, there is no measurable difference.)This should also fix a memory leak that happens when factory files contain closures.