Skip to content
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

Optimize container rebuilding #111

Closed
pkruithof opened this issue Jun 12, 2013 · 4 comments
Closed

Optimize container rebuilding #111

pkruithof opened this issue Jun 12, 2013 · 4 comments

Comments

@pkruithof
Copy link

We have quite a lot of services in our project, and we noticed our development environment getting really slow. Doing some benchmarks I found out that building the container takes longer than without the @DI\Service annotations (between 13s and 20s with, and ~12s without). Which makes perfect sense of course, given that this bundle needs to check all the files for annotations.

However when working in a service, the container gets built with every save, as the resource is modified. This really slows down development a lot. I've been thinking if this can be optimized.

Since only the annotations are used for configuring the services, it would make sense to only add the annotations to the container's resources, not the whole service. Would it be possible to use the cached annotation/metadata of a class as container resource instead? This way only a changed annotation would trigger a container rebuild.

@schmittjoh
Copy link
Owner

12s is really slow in general. The performance of this bundle in
development mostly depends on the speed of your harddisk. If you for
example are using a network drive, then you will see greatly increased
build times.

Your suggested optimization should be possible, though it will not be
trivial to implement as the MetadataFactory and drivers would need to be
serialized. If you can find out where the time is spent, it might be possible
to find an easier solution.

On Wed, Jun 12, 2013 at 3:24 PM, Peter Kruithof notifications@github.comwrote:

We have quite a lot of services in our project, and we noticed our
development environment getting really slow. Doing some benchmarks I found
out that building the container takes longer than without the @di\Serviceannotations (between 13s and 20s with, and ~12s without). Which makes
perfect sense of course, given that this bundle needs to check all the
files for annotations.

However when working in a service, the container gets built with every
save, as the resource is modified. This really slows down development a
lot. I've been thinking if this can be optimized.

Since only the annotations are used for configuring the services, it would
make sense to only add the annotations to the container's resources, not
the whole service. Would it be possible to use the cached
annotation/metadata of a class as container resource instead? This way only
a changed annotation would trigger a container rebuild.


Reply to this email directly or view it on GitHubhttps://github.com//issues/111
.

@pkruithof
Copy link
Author

I'm running Symfony in a Vagrant/Virtualbox VM with a shared NFS folder, on a MacBook Pro with SSD. So I doubt that's the problem. I dug inside the builder process: the compiler passes that took more than 0.1s are these:

total time: 10.16614818573

Symfony\Component\DependencyInjection\Compiler\ReplaceAliasByActualDefinitionPass:           float 2.6725289821625
Symfony\Component\DependencyInjection\Compiler\RepeatedPass:                                 float 2.4776499271393
Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass:            float 1.6505689620972
Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ContainerBuilderDebugDumpPass:   float 0.62428593635559
Symfony\Component\DependencyInjection\Compiler\CheckCircularReferencesPass:                  float 0.5435791015625
Symfony\Component\DependencyInjection\Compiler\ResolveParameterPlaceHoldersPass:             float 0.54308390617371
JMS\AopBundle\DependencyInjection\Compiler\PointcutMatchingPass:                             float 0.25508499145508
Symfony\Component\DependencyInjection\Compiler\AnalyzeServiceReferencesPass:                 float 0.22207403182983
Symfony\Component\DependencyInjection\Compiler\CheckReferenceValidityPass:                   float 0.20338201522827
Symfony\Component\DependencyInjection\Compiler\ResolveReferencesToAliasesPass:               float 0.15316987037659
Symfony\Component\DependencyInjection\Compiler\ResolveInvalidReferencesPass:                 float 0.12055706977844
Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass: float 0.10745406150818

All built-in as you can see. To be fair, compiling locally on my Mac takes 2s, but that messes up hard-coded file paths in the cache files, so that's not really an option for my setup.

Any thoughts on this?

@pkruithof
Copy link
Author

Hm, another project (different VM) takes just 3s, so I guess something's wrong with this one. Ignore the previous comment.

However, I'd still like it if this feature could be implemented.

@EmmanuelVella
Copy link

Same issue on 2 different project with 1.4.0 version : changing a service file makes the next page loading very long.

I'm using php 5.5 and Xdebug is disabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants