Merge lp:~jtv/launchpad/bug-515702 into lp:launchpad
Proposed by
Jeroen T. Vermeulen
Status: | Merged |
---|---|
Approved by: | Muharem Hrnjadovic |
Approved revision: | not available |
Merged at revision: | not available |
Proposed branch: | lp:~jtv/launchpad/bug-515702 |
Merge into: | lp:launchpad |
Diff against target: |
12 lines (+1/-1) 1 file modified
lib/lp/translations/browser/translations.py (+1/-1) |
To merge this branch: | bzr merge lp:~jtv/launchpad/bug-515702 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Muharem Hrnjadovic (community) | code | Approve | |
Review via email: mp+18411@code.launchpad.net |
Commit message
Speed up Distribution/
To post a comment you must log in.
= Bug 515702 =
We're getting timeouts on the Distribution and DistroSeries translation overviews. In each of the oopses I saw, a majority of time was spent querying Language, Country, and the linking table between the two (in roughly a 2:1:1 ratio). These are very simple queries, but insanely repetitive: the top query is looking up a Language by language code several thousand times for one page. Given that we only have a few hundred languages in the database, we clearly need some caching.
It turns out that the timeouts all happened while the browser code was figuring out whether a given language is among the user's preferred languages, as determined based on user preference settings and http request parameters. Each of these checks again queried the full lists of these languages from the database. The check is needed because by default, we now hide non-preferred languages in the displayed page.
To speed this up, I made the TranslationsMix in.translatable _languages property cached. This is browser code, so should be perfectly safe to cache. Doing so breaks no browser or stories tests. As far as Henning and I can tell, there is no reason not to make this property cached except that it wasn't called so repetitively in the past.
No lint. No tests are affected; there is no semantical change, only a performance improvement on large, lifelike data sets. If the change does break anything, that's a hole in our existing test coverage which we can't realistically know about unless and until something does break.
Jeroen