Repository navigation
Conversation
On a locale with thousands of overrides, the reads behind a catalogue view and the translator's cache miss spent their time outside the database: the grouped read built an entity per override of the browsed locale, and three merges re-ranked both locales in every comparison of their sort. - The grouped read selects the key, the catalogue and the value of each override as a scalar row (findValuesByLocaleAndCatalogues() replaces findByLocaleAndCatalogues(), which only it used). - The effective overrides of a locale and the inherited values are bucketed by precedence instead of sorted. - The translator ranks each row once before sorting. With 5,018 overrides in fr_FR and in fr: the grouped read of 26 catalogues goes from about 225 ms to 80 ms, the effective overrides of seven locales from about 250 ms to 80 ms. The results are unchanged.
This file contains hidden or 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
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.
What this pull request does
On a locale with thousands of overrides, the reads behind a catalogue view and the translator's cache miss spent their time outside the database: the grouped read built an entity per override of the browsed locale, and three merges re-ranked both locales (
LocaleFallback::rank()) in every comparison of their sort.OverrideReader::getTranslationsForCatalogues()reads the key, the catalogue and the value of each override of the browsed locale as a scalar row:TranslationOverrideRepository::findValuesByLocaleAndCatalogues()replacesfindByLocaleAndCatalogues(), which only it used. The repository is not part of the public contract.getEffectiveOverridesByCatalogue(), behind the coverage report and the reference columns of a view) and the inherited values of a view.The results are unchanged: the precedence and its tie-breaks are the same, and the existing tests of the translator, the reader and the coverage pass as they are. The unit tests that stubbed the removed repository method now stub the new one.
Measured from the Sylius plugin's test application (MariaDB), 26 catalogues, 5,018 overrides in
fr_FRand infr:getTranslationsForCatalogues(),fr_FR, 26 cataloguesgetEffectiveOverridesByCatalogue(), 7 localestrans()infr_FR, override cache emptyWith 500 overrides per locale, the first two go from about 20 - 30 ms to 11 - 14 ms. The query count does not change.
Points to watch
vendor/bin/phpunit): 692 testsvendor/bin/phpstan analyse,vendor/bin/php-cs-fixer check)UPGRADE.mdis up to date if the public contract changes: everythingdocs/public-contract.mdlists, method signatures included - nothing changes: the repository is internal, and every listed method keeps its signature and its resultdocs/adr/- noneIf the pull request touches the entity mapping
It does not.
If the pull request touches a provider bridge
It does not.