Last modified: 2013-05-17 14:13:44 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T32425, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 30425 - Parser should cache the output of identical template calls as well as parameterless calls
Parser should cache the output of identical template calls as well as paramet...
Status: REOPENED
Product: MediaWiki
Classification: Unclassified
Parser (Other open bugs)
1.20.x
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
: performance
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-08-17 17:59 UTC by Happy-melon
Modified: 2013-05-17 14:13 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Happy-melon 2011-08-17 17:59:30 UTC
At http://en.wikipedia.org/w/index.php?diff=prev&oldid=445197792 we see an edit which changed a huge number of calls to {{rating|1|3}} to calls to {{rating 1 3}}, which is a wrapper template which merely contains the former call.  Doing so slashes all the parser statistics: preprocessor node count down by 96%, post-expand down by 89%, template argument size down by 99.9%.  I haven't looked in detail about why this is, but some sort of beneficial caching is definitely not occuring in the more common case, and it should.
Comment 1 Daniel A. R. Werner 2011-10-14 21:33:12 UTC
By caching templates, it shouldn't be forgotten that they could contain dynamic or randomly generated content, so it should be possible for parser functions to disable the cache, of course this must be done recursively then. I am not sure whether this is the case already, I just recall Extension:Variables behaving buggy on cached templates and when I last checked I think there already was some way for preventing caching but it didn't really work... Guess I will look into this again soon.
Comment 2 Tim Starling 2011-11-07 10:29:54 UTC
The reason the template expansion cache is only for invocations with empty arguments is just the difficulty of the implementation. I left it for later. 

A naive implementation would involve traversing the whole tree under the <part> in order to generate a hash for fetching the expansion. That's O(N) in the node count, and if you had nested arguments, it becomes O(N^2) in the string length. It's a design goal to avoid such O(N^2) cases. So it's necessary to store subtree hashes in each of the node objects, which complicates construction slightly.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links