-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Improve Translator caching #28937
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
Improve Translator caching #28937
Conversation
702a748
to
5a4d9dc
Compare
5a4d9dc
to
1499edc
Compare
1499edc
to
28da4d2
Compare
Rebased and force pushed to fix merge conflict. Could I get a review here please? 🙂 |
28da4d2
to
6fdd6d3
Compare
Rebased again. Could you have a look please @nicolas-grekas? 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good thanks. Here are some comments. Would it be possible to add some test cases also?
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Show resolved
Hide resolved
039ecd6
to
d7ed632
Compare
@nicolas-grekas I've rebased onto master and stopped using This prevents a full container rebuild if any of the translation directories it was tracking but did not exist is created - it will only rebuild the Catalogue in that case, which is much faster. I've also added some tests. Could you check again please? 🙂 |
9c9b618
to
bf6afed
Compare
Failing tests are unrelated (I think). |
This PR makes sure that catalogues also track directories that were found empty when scanning for translation files, where they didn't before. So yes, if I understand correctly this PR is also a fix for your problem, @welcoMattic 🙂 |
bf6afed
to
c4b40e3
Compare
Rebased on master again. This time the failed build on Travis is definitely unrelated 🙂 Ping @nicolas-grekas, could you review again please? |
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Outdated
Show resolved
Hide resolved
The list of files being loaded is still built by the container. So AFAICT, this change does not allow removing the resources at the container-level (we would still need to build the new list). |
This change is already removing the resources from the container, and everything works fine without the container knowing where translations files reside. Why would it need to know about those? The only reason I can think of is if I add another translations path to the framework, but then the resource where I define that is not fresh anymore, so the container would be rebuilt, and the change would cascade to the catalogues. |
Comments processed @fabpot. Could you check again please? |
Think it's right now but @fabpot should have a quick look still. |
Thank you @rpkamp. |
This PR was squashed before being merged into the 4.3-dev branch (closes #28937). Discussion ---------- Improve Translator caching | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #27600 | License | MIT | Doc PR | N/A Add DirectoryResources to MessageCatalogues when loaded. So that when a file is added to one of the directories the cache for all MessageCatalogues will be invalidated. All directories must be added to all MessageCatalogues because we can't predict for which locale files will be added to each individual directory. Also, now that the translator keeps track of its own directories for caching the container no longer needs to it. This means that when a translation changes or is added the container no longer needs to be fully rebuilt, saving a considerable amount of time (compilation time went down from ~4 seconds to ~1 second on each translation change/add in our project). Commits ------- a524658 Improve Translator caching
@fabpot label? ;) |
@curry684 oops, fixed |
…ache for translation files (javiereguiluz) This PR was merged into the 4.3 branch. Discussion ---------- [Translation] Mention that you don't have to clear the cache for translation files Mentions the nice new behavior implemented in symfony/symfony#28937. Commits ------- ddf97c7 [Translation] Mention that you don't have to clear the cache for translation files
Add DirectoryResources to MessageCatalogues when loaded.
So that when a file is added to one of the directories the cache for all MessageCatalogues will be invalidated.
All directories must be added to all MessageCatalogues because we can't predict for which locale files will be added to each individual directory.
Also, now that the translator keeps track of its own directories for caching the container no longer needs to it. This means that when a translation changes or is added the container no longer needs to be fully rebuilt, saving a considerable amount of time (compilation time went down from ~4 seconds to ~1 second on each translation change/add in our project).