Page MenuHomePhabricator

Cache SnakFormat::getFallbackChain() inside the class
Closed, ResolvedPublic5 Estimated Story Points


For a simple page that doesn't use much data: Wikibase\Lib\Formatters\SnakFormat::getFallbackChain is being called 9000 times, that doesn't make much sense plus the time is spent inside the method is pretty large (40ms) for something close to non-existent. Caching the fallback chain inside the SnakFormat class as a class attribute for now would give a performance boost.


Acceptance Criteria🏕️🌟 :

  • Do not regenerate the array returned from SnakFormat::getFallbackChain thousands of times

It was suggested in story time that perhaps this method could be thrown away and the callers reworked to be more efficient

Event Timeline

Addshore set the point value for this task to 5.

I'm not sure if it's worth doing now. Possibly due to lots of refactoring that page I linked is now only call that function 50 times instead of 9k times. Even for Alan Turing category which has a quite large data it calls it 800 times and takes 2ms (in a request taking 13 seconds)

Change 710036 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@master] Simplify SnakFormat implementation

Change 710036 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Simplify SnakFormat implementation