-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI] Allow dumping the container in one file instead of many files #32581
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
143a701
to
256e765
Compare
This will need some tests. At least functional tests, to unsure we can boot() the kernel (several times) |
4c1a9b2
to
685ff7f
Compare
685ff7f
to
c893986
Compare
Unit tests added.
not added because this would be unrelated: this PR changes absolutely nothing in terms of how the container is loaded. |
What are the pros/cons of setting |
We demonstrated in the past that loading a set of smaller files is faster than loading a single big container file. The drawback that @lyrixx experienced is found on workers: because they are long-running, they are more likely to be affected by the removal of one of those files. This doesn't happen for requests that reload everything all the time. What is unknown is how PHP 7.4 will change the situation regarding performance. With preloading, a single big file can, in theory, be similarly fast or faster. But anyway, we're not going to support only PHP 7.4. If that's confirmed, we'll be able to have a recipe that sets this param to true on PHP 7.4, and drop that in Symfony 6. |
Why would a file be removed? Sounds like a deployment problem. |
On dev I suppose, it disrupts the workflow. |
Yes it's in development of course 👍 |
I'm merging this to move forward. We might consider defaulting or sticking to one way or another, but we need to be able to compare first. |
…f many files (nicolas-grekas) This PR was merged into the 4.4 branch. Discussion ---------- [DI] Allow dumping the container in one file instead of many files | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Replaces #32119 As spotted by @lyrixx, putting all service factories in one big container can be easier to manage with workers. It could also play well with PHP7.4's preloading. This PR adds a `container.dumper.inline_factories` parameter to enable this behavior. When it is set to true, a single big container file is created. Commits ------- c893986 [DI] Allow dumping the container in one file instead of many files
Thanks @nicolas-grekas for this one :) |
This PR was merged into the 4.4 branch. Discussion ---------- Fix OPcache class preload requirement `container.dumper.inline_factories` As stated by @nicolas-grekas in symfony/symfony#32581 (comment) > With preloading, a single big file can, in theory, be similarly fast or faster. `container.dumper.inline_class_loader` With this parameter set to `true`, we'll do extra `include_once` for classes already preloaded by OPcache. Additionally, it can lead to warnings (cannot redeclare class) in classes that use `class_alias`, like https://github.com/FriendsOfSymfony/FOSHttpCacheBundle/blob/master/src/EventListener/InvalidationListener.php#L33 It's because this class already declared in preload, and PHP tries to declare it again after `include_once` in service getter. Commits ------- cc151fc Remove incorrect opcache preload instructions
Replaces #32119
As spotted by @lyrixx, putting all service factories in one big container can be easier to manage with workers. It could also play well with PHP7.4's preloading.
This PR adds a
container.dumper.inline_factories
parameter to enable this behavior.When it is set to true, a single big container file is created.