Skip to content

Circular deps graph is unproportionally huge #37540

@markomitranic

Description

@markomitranic

Symfony version(s) affected: 3.4.42

Description
My team is experiencing huge issues with container built times on Symfony 3.4.42. We are working heavily on performing the update to 4.4 (which does not exhibit the same issue). We have observed this issue on earlier versions, and can track them back to 3.4.37, before which we have no reliable data.

But thisis an interesting sight, and it would mean quite a lot if i could get @nicolas-grekas thoughts on this particular Blackfire profile. < This is a cold start, a first pageload of an application without var/cache/*...

As you might imagine, 29 million method calls takes quite a lot of time, and prevents us from using xdebug at all (its not installed in the container that was used to make the abovementioned profile), or often makes blackfire probe unavailable because of timeouts. We do have about ~1500 manually registered services, most of which use autowiring and autoconfiguration, and we do not let the app scan for services automagically.

Any kind of hint would help. <3

How to reproduce
This is very tough to reproduce as i have absolutely no idea what the minimum viable code amount would be, as the problem seems thightly scaling with the sheer number of autowired services (1693).

If anyone has any ideas on how i can make a reproducer, feel free to tell me. For reference here are a few examples of what may be found in our services.yml

    App\CoreBundle\DependencyInjection\MetaTagsService:
        autoconfigure: true
        autowire: true

    App\CoreBundle\DependencyInjection\CustomListService:
        autoconfigure: true
        autowire: true
        arguments:
            - '@service_container'
            - '@doctrine.odm.mongodb.document_manager'
            - '@geo_target'
            - '@translator'
        tags:
            - { name: doctrine_mongodb.odm.event_listener, event: prePersist }

    redirection_service:
        class: App\CoreBundle\DependencyInjection\RedirectionService
        arguments:
            - '@activity_log_service'
        tags:
            - { name: doctrine_mongodb.odm.event_listener, event: prePersist }
            - { name: doctrine_mongodb.odm.event_listener, event: preUpdate }
            - { name: doctrine_mongodb.odm.event_listener, event: postFlush }

    App\CoreBundle\Service\AgCash\AgCoinStatusService:
        autowire: true
        autoconfigure: true
        arguments:
            $transformer: '@App\CoreBundle\Service\Transformer\API\General\QuickSearch\QuickSearchOutputTransformer'
            $translator: '@translator'
            $authorizationChecker: '@security.authorization_checker'
            $currentCountryProvider: '@current_country_provider'

Possible Solution
Not yet. :(

Additional context
The BF profile is clearly pointing to 3 methods that perform 29M loops, but dumping the variables inside the methods shows nothing unexpected. $this->circularReferences is at count 168, total number of services is 1693.

My best guess was that this is related to the fix in #29336 and the fact that @nicolas-grekas seem to have rolled back on some of the changes as of this commit because of compatibility reasons. But, i am by no means an expert on the topic, and need help interpreting some of the changes made in those two.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions