Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[HttpKernel] Ignore autowiring errors on controllers unless argument's type is an interface#46275

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

@nicolas-grekas
Copy link
Member

QA
Branch?6.1
Bug fix?no
New feature?no
Deprecations?no
Tickets-
LicenseMIT
Doc PR-

While inspecting the dumped container of the demo app, I noticed that it contains so-called "errored" services.
Those come from controllers' arguments: when computing the service locator for the argument resolver, entities found as type hints are obviously not found by the autowiring logic since they're not services.

When this happens, we register an errored service in case this entity-class is fetched from the service argument resolver. The issue is that in order to compute the related error messages (to be maybe thrown at runtime), the autowiring logic needs to inspect all services for alternatives. This is a heavy process that is useless in this situation.

This PR proposes to simply skip computing those error messages when an argument is type-hinted witha class. In practice, this means that some error messages might become less informative. To alleviate this drawback, we keep computing those error messages in case an argument referencesan interface.

On the demo app, this removes any errored definitions from the dumped container. This should improve the dumping compilation time a bit (not measurable on the demo app though.)

@chalasr
Copy link
Member

chalasr commentedMay 5, 2022
edited
Loading

this means that some error messages might become less informative.

Could we improve the "default" error message to make it hint about more potential causes?

(not measurable on the demo app though.)

Is it really worth the DX loss then? There is still quite a lot of non-abstracted services in userland...

@nicolas-grekas
Copy link
MemberAuthor

Is it really worth the DX loss

I now measure a 2% perf boost after fixing#46276
Might be more important on bigger apps.
This is both a DX loss (potentially less informative messages) and a DX win (faster compile time + freshness checks).

There is still quite a lot of non-abstracted services in userland...

An error about a missing argument when calling a controller will still tell about its type. If it's a userland class, then I suppose ppl will be able to figure out their own stuff without much trouble.

Could we improve the "default" error message to make it hint about more potential causes?

I'm not sure: the error message will tell about argument resolving that failed, and this part knows nothing about services/autowiring.

But let me try another approach before going this way. There might be a lower-level one to short-circuit this heavy logic in AutowirePass. 🤞

chalasr reacted with thumbs up emoji

@nicolas-grekas
Copy link
MemberAuthor

Replaced by#46279

@nicolas-grekasnicolas-grekas deleted the clean-ctrl-locator branchMay 6, 2022 10:57
nicolas-grekas added a commit that referenced this pull requestMay 27, 2022
…ling it about excluded symbols (nicolas-grekas)This PR was merged into the 6.2 branch.Discussion----------[DependencyInjection] Optimize autowiring logic by telling it about excluded symbols| Q             | A| ------------- | ---| Branch?       | 6.1| Bug fix?      | no| New feature?  | yes| Deprecations? | no| Tickets       | -| License       | MIT| Doc PR        | -Replaces#46275While inspecting the dumped container of the demo app, I noticed that it contains so-called "errored" services. They come e.g from entities that are used as type-hints on controllers. To compute those services, the autowiring logic currently loads all services looking for possible type-compatible candidates.But here, we should know that those won't be found: they're excluded from being loaded.Instead of completely ignoring excluded classes, this PR still registers them, but as abstract and with a special `container.excluded` tag.This allows the rest of the compilation logic to skip+remove them, while allowing `AutowiringPass` to compute a better error message and way faster.Here is the relevant part of ahttps://blackfire.io comparison:![image](https://user-images.githubusercontent.com/243674/167118702-383a3cd5-a176-4e9f-9218-de48a84fcab3.png)Commits-------739789f [DependencyInjection] Optimize autowiring logic by telling it about excluded symbols
symfony-splitter pushed a commit to symfony/framework-bundle that referenced this pull requestMay 31, 2022
…ling it about excluded symbols (nicolas-grekas)This PR was merged into the 6.2 branch.Discussion----------[DependencyInjection] Optimize autowiring logic by telling it about excluded symbols| Q             | A| ------------- | ---| Branch?       | 6.1| Bug fix?      | no| New feature?  | yes| Deprecations? | no| Tickets       | -| License       | MIT| Doc PR        | -Replacessymfony/symfony#46275While inspecting the dumped container of the demo app, I noticed that it contains so-called "errored" services. They come e.g from entities that are used as type-hints on controllers. To compute those services, the autowiring logic currently loads all services looking for possible type-compatible candidates.But here, we should know that those won't be found: they're excluded from being loaded.Instead of completely ignoring excluded classes, this PR still registers them, but as abstract and with a special `container.excluded` tag.This allows the rest of the compilation logic to skip+remove them, while allowing `AutowiringPass` to compute a better error message and way faster.Here is the relevant part of ahttps://blackfire.io comparison:![image](https://user-images.githubusercontent.com/243674/167118702-383a3cd5-a176-4e9f-9218-de48a84fcab3.png)Commits-------739789f384 [DependencyInjection] Optimize autowiring logic by telling it about excluded symbols
symfony-splitter pushed a commit to symfony/http-kernel that referenced this pull requestJun 6, 2022
…ling it about excluded symbols (nicolas-grekas)This PR was merged into the 6.2 branch.Discussion----------[DependencyInjection] Optimize autowiring logic by telling it about excluded symbols| Q             | A| ------------- | ---| Branch?       | 6.1| Bug fix?      | no| New feature?  | yes| Deprecations? | no| Tickets       | -| License       | MIT| Doc PR        | -Replacessymfony/symfony#46275While inspecting the dumped container of the demo app, I noticed that it contains so-called "errored" services. They come e.g from entities that are used as type-hints on controllers. To compute those services, the autowiring logic currently loads all services looking for possible type-compatible candidates.But here, we should know that those won't be found: they're excluded from being loaded.Instead of completely ignoring excluded classes, this PR still registers them, but as abstract and with a special `container.excluded` tag.This allows the rest of the compilation logic to skip+remove them, while allowing `AutowiringPass` to compute a better error message and way faster.Here is the relevant part of ahttps://blackfire.io comparison:![image](https://user-images.githubusercontent.com/243674/167118702-383a3cd5-a176-4e9f-9218-de48a84fcab3.png)Commits-------739789f384 [DependencyInjection] Optimize autowiring logic by telling it about excluded symbols
symfony-splitter pushed a commit to symfony/dependency-injection that referenced this pull requestJun 7, 2022
…ling it about excluded symbols (nicolas-grekas)This PR was merged into the 6.2 branch.Discussion----------[DependencyInjection] Optimize autowiring logic by telling it about excluded symbols| Q             | A| ------------- | ---| Branch?       | 6.1| Bug fix?      | no| New feature?  | yes| Deprecations? | no| Tickets       | -| License       | MIT| Doc PR        | -Replacessymfony/symfony#46275While inspecting the dumped container of the demo app, I noticed that it contains so-called "errored" services. They come e.g from entities that are used as type-hints on controllers. To compute those services, the autowiring logic currently loads all services looking for possible type-compatible candidates.But here, we should know that those won't be found: they're excluded from being loaded.Instead of completely ignoring excluded classes, this PR still registers them, but as abstract and with a special `container.excluded` tag.This allows the rest of the compilation logic to skip+remove them, while allowing `AutowiringPass` to compute a better error message and way faster.Here is the relevant part of ahttps://blackfire.io comparison:![image](https://user-images.githubusercontent.com/243674/167118702-383a3cd5-a176-4e9f-9218-de48a84fcab3.png)Commits-------739789f384 [DependencyInjection] Optimize autowiring logic by telling it about excluded symbols
symfony-splitter pushed a commit to symfony/framework-bundle that referenced this pull requestJul 28, 2023
…ling it about excluded symbols (nicolas-grekas)This PR was merged into the 6.2 branch.Discussion----------[DependencyInjection] Optimize autowiring logic by telling it about excluded symbols| Q             | A| ------------- | ---| Branch?       | 6.1| Bug fix?      | no| New feature?  | yes| Deprecations? | no| Tickets       | -| License       | MIT| Doc PR        | -Replacessymfony/symfony#46275While inspecting the dumped container of the demo app, I noticed that it contains so-called "errored" services. They come e.g from entities that are used as type-hints on controllers. To compute those services, the autowiring logic currently loads all services looking for possible type-compatible candidates.But here, we should know that those won't be found: they're excluded from being loaded.Instead of completely ignoring excluded classes, this PR still registers them, but as abstract and with a special `container.excluded` tag.This allows the rest of the compilation logic to skip+remove them, while allowing `AutowiringPass` to compute a better error message and way faster.Here is the relevant part of ahttps://blackfire.io comparison:![image](https://user-images.githubusercontent.com/243674/167118702-383a3cd5-a176-4e9f-9218-de48a84fcab3.png)Commits-------739789f384 [DependencyInjection] Optimize autowiring logic by telling it about excluded symbols
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

6.1

Development

Successfully merging this pull request may close these issues.

3 participants

@nicolas-grekas@chalasr@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp