Page MenuHomePhabricator

MessageCache generates high number of memcache GETs for nonexistent messages
Open, LowPublic

Description

In T193271, MessageCache was refactored to limit the set of message pages included in the main blob to overrides of messages defined in code and LanguageConverter conversion table subpages. Effectively, this means that fetching a message from MessageCache that does not fall into these categories will trigger a fetch from APCu -> memcache -> DB, since the message will not be found in the main blob, but may be overridden locally.

Unfortunately, on a vanilla install, there are many cases where a nonexistent message is looked up in MessageCache:

  • Legacy pre-Vector action name messages. All SkinTemplate-based skins try to look up pre-Vector message variants for various content action related i18n strings in SkinTemplate::buildContentNavigationUrls. Example: $skname-view-foreign -> view-foreign. In this particular case, skins like Vector have $skname- overrides defined in code for some of the messages, e.g. vector-view-edit, but not for all of them.
  • Linker. Methods such as accesskey and titleAttrib check for the existence of messages like accesskey-$name or tooltip-$name, which might not be defined in code.
  • LanguageConverter namespace variants. LanguageConverter::convertNamespace checks if there is a converted name defined for a given namespace in a conversion-ns$namespaceIndex message for the target language variant, or the content language. This method may be called in a loop by e.g. Language::getNamespaceAliases, which is indirectly invoked on most pageviews.

In Fandom's MW 1.33 install, memcache fetches triggered by MessageCache for the aforementioned cache miss code path totaled ~30k requests per second, or ~17% of all memcache requests. In the interim, we created an extension to eliminate most of these fetches in our setup.

The below graph shows the drop in memcache requests made via WANObjectCache after the aforementioned improvement was deployed.

Screenshot 2021-02-17 at 15.22.46.png (744×1 px, 641 KB)

In the case of e.g. Wikimedia's setup, the number of fetches from MessageCache is much lower, likely due to the large APCu SHM allowing most of the messages to be stored in APCu, TTL improvements in rMW1d7f7931082281ab4cac2b4391113d80aee1ea41 and overall less individual wikis. However, per a conversation with @Krinkle, this MessageCache behavior seems to be an unintentional side-effect of the T193271 refactor, so I'm creating this ticket to discuss if anything should be changed.

Event Timeline

aaron triaged this task as Low priority.Oct 5 2022, 7:11 PM