-
-
Notifications
You must be signed in to change notification settings - Fork 341
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
[Translator] Many performance improvements on the cache warming #2206
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…MessageParser#offset()`
… `IntlMessageParser#generateConstantName()`
… to `->slice($offset, 1)`
…revent unnecessary computations
969c6cf
to
1309032
Compare
smnandre
reviewed
Sep 26, 2024
smnandre
reviewed
Sep 26, 2024
smnandre
reviewed
Sep 26, 2024
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.
Trusting you here :)
7b38d80
to
4f3c9e4
Compare
4f3c9e4
to
02e1eb3
Compare
kbond
approved these changes
Sep 26, 2024
smnandre
approved these changes
Sep 26, 2024
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.
🤝
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Symfony UX Translator cache warmer can be an long task, especially if your app has a lot of translations.
I was able to identify some bottlenecks and fix them, with a dedicated commit for each of them.
My test application have ~25k translation keys (3.119 keys * 8 locales). Of course that's a lot, but I believe some people needs to dump all their translations (e.g. if they build an SPA on Symfony). For "more classic" applications, it is recommended to use dedicated domains for translations JS-side.
Anyway, in my application, I was able to reduce the Translator cache warming from 2m11s (higher than the reality, because of Blackfire profiling) to 41s (higher than the reality, because of Blackfire profiling):

The vast majority of improvements come from better use of the Symfony String component.
Blackfire profiles:
s()
instancess()->slice()
$this->message->length()
as it will always return the same lengthAlso, since the Translator component is still experimental, I've marked some classes as final and internal, as they should only be used internally. :)