No translation round-trip on every page load
Session info now carries a hash of the translations, so the client only fetches them when they changed. This saves a request of about 6–7 ms of worker time per page view in the backend and on the website.
Session info now carries a hash of the translations, so the client only fetches them when they changed. This saves a request of about 6–7 ms of worker time per page view in the backend and on the website.
| Branch | Pull request | Commit |
|---|---|---|
| 19.0 | odoo/odoo#292294 ↗ | 6edb059617 ↗ |
| 20.0 | odoo/odoo#294138 ↗ | 1c86b822d8 ↗ |
[PERF] base: skip fetching up-to-date translations web, http_routing, website On every page load, in the backend and on the website, the localization service fetched the translations (/web/webclient/translations or /website/translations) to check whether the ones stored in IndexedDB were still current, even when they were. That check cost a full request per page view, about 6-7 ms of worker time. The session info now contains the hash of the translations that the translations endpoint would return, so the client only fetches them when its stored hash differs. The hash is only taken from the ormcache, with the new ormcache.get_value(), which returns a cached value without computing it: building the hash requires building all the translations, which must not slow down page rendering. On a cold cache the session info has an empty hash, so the client fetches the translations as before, which fills the cache for the next page loads. Website pages served from the page cache get the current hash, as the page may have been cached while the hash wasn't. The default modules and the language check (a language that isn't installed becomes None) used by the translations endpoint are moved to ir.http._get_web_translations_modules and _get_web_translations_lang, next to _get_web_translations_hash, so the endpoint and the session info always hash the same modules and language. With 4 workers, 5 languages and the translations fetched in the background, the worker time per page view goes from 20.5 to 14.1 ms on the website and from 21.9 to 13.6 ms in the backend, without changing the cost of the page itself.