Code review comment for lp:~jtv/launchpad/bug-515702

Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

= 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 TranslationsMixin.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

« Back to merge proposal