Page MenuHomePhabricator

Improve parser cache expiry mechanism for message bundle dependents
Open, MediumPublic

Description

As part of T359918: Lua interface for convenient access to translations in a message bundle we implemented a simple cache expiry mechanism that invalidates the cache of all templates that use the message bundle whenever the message bundle is updated or a translation is made.

This is wasteful because irrespective of what language translation is made, all the templates using the message bundle are purged.

A few things to keep in mind:

  • There’s no easy way to determine the affected pages when a message bundle is updated. Especially as the requested message bundle language can be user-controlled, so checking the page language isn’t enough.
  • We use the language fallback chain (unless explicitly disabled by the module calling us), so if a translation doesn’t exist, all non-existing translations in the chain (in case one of them is created) and the first existing message in the chain (in case it’s edited – or deleted) need to be tracked.
  • Considering tracking dependencies on a key level. There is a possibility that multiple templates might decide to use a single large message bundle.
  • For Commons, depending on the approach we take here, we may have to put dependency tracking behind a feature flag or have our own table that tracks the dependencies.
  • In an ideal scenario one bundle will serve one module, causing most of the individual messages to be used on most pages using the module/bundle.

Event Timeline

  • In an ideal scenario one bundle will serve one module, causing most of the individual messages to be used on most pages using the module/bundle.

Even if a bundle corresponds to a single module, it doesn’t necessarily mean that most messages are used on most pages – for example, an infobox may have a lot of fields (with each field having a label) but with most of them left empty most of the time.