Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DI] Put non-shared service factories in closures #25867

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

Merged
merged 1 commit into from
Feb 4, 2018

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Jan 20, 2018

Q A
Branch? master
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

With this change, non-shared services are moved to dedicated files (unless they are on the hot path).
Previously, they were always dumped as methods.

The goal of this change is to dump factories as methods if and only if the services they build are on the hot-path. By doing so, it will become very easy to figure out which services are on the hot path, vs the rest. And then people will be able to optimize their configurations: if too many things are dumped as methods, it will trivially mean some laziness is missing in definitions.

I spotted this while reviewing the dumped container of Blackfire, where we sometimes have long chains of dependencies that are on the hot path for no real reason - mixed with big non-shared factories (Sonata admin blocks in our case.)

@nicolas-grekas nicolas-grekas added this to the 4.1 milestone Jan 20, 2018
@nicolas-grekas nicolas-grekas force-pushed the non-shared-factories branch 3 times, most recently from 09057ef to d35a530 Compare January 20, 2018 23:47
@nicolas-grekas nicolas-grekas added RFC RFC = Request For Comments (proposals about features that you want to be discussed) Ready and removed Ready RFC RFC = Request For Comments (proposals about features that you want to be discussed) labels Jan 23, 2018
@nicolas-grekas nicolas-grekas merged commit 22c5325 into symfony:master Feb 4, 2018
nicolas-grekas added a commit that referenced this pull request Feb 4, 2018
…as-grekas)

This PR was merged into the 4.1-dev branch.

Discussion
----------

[DI] Put non-shared service factories in closures

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

With this change, non-shared services are moved to dedicated files (unless they are on the hot path).
Previously, they were always dumped as methods.

The goal of this change is to dump factories as methods *if and only if* the services they build are on the hot-path. By doing so, it will become very easy to figure out which services are on the hot path, vs the rest. And then people will be able to optimize their configurations: if too many things are dumped as  methods, it will trivially mean some laziness is missing in definitions.

I spotted this while reviewing the dumped container of Blackfire, where we sometimes have long chains of dependencies that are on the hot path for no real reason - mixed with big non-shared factories (Sonata admin blocks in our case.)

Commits
-------

22c5325 [DI] Put non-shared service factories in closures
@nicolas-grekas nicolas-grekas deleted the non-shared-factories branch February 12, 2018 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants