Content deleted Content added
heading |
→Performance: Replied |
||
Line 31:
Recently {{ping|Johnuniq}} developed {{tlx|NUMBEROF}} which uses [[c:Data:Wikipedia statistics/data.tab]] generated by GreenC bot. One of the issues we ran into was performance, because each time the template is invoked, the Commons file is retrieved via mw.ext.data.get() which is slow. [[List of Wikipedias]] had over 4,000 invocations which exceeded Lua's 10 second time and rendered red errors. {{ping|Pppery}} suggested a solution to load the Commons file 1 time per page but mw.ext.data.get() does not support this, however mw.loadData() does. So the mw.ext.data.get() is used in {{tlx|NUMBEROF/data}} which is then loaded by mw.loadData() in {{tlx|NUMBEROF}}. It works to ensure the file from Commons is loaded 1 time regardless of how often the module is invoked on a page. Is this an issue with this module? Should we recommend readers to use {{tlx|NUMBEROF}} vs. this template, since it is being used as an example? -- [[User:GreenC|<span style="color: #006A4E;">'''Green'''</span>]][[User talk:GreenC|<span style="color: #093;">'''C'''</span>]] 02:26, 24 May 2020 (UTC)
:[[Module:NUMBEROF/data]] is easily able to provide a cache of the Commons data because the module was written specifically for that data format, and with knowledge of what was wanted by the main module. To do that more generally would be tricky. Using hundreds of calls to [[Module:Tabular data]] would consume a lot of resources. If that is ever required, I would think a workable solution would require a custom module like Module:NUMBEROF/data. Re the question: yes, {{tl|NUMBEROF}} should be used although I suppose the example in the docs here was intended to show this module's flexibility. I think the docs should include a "but see {{tl|NUMBEROF}}" note. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 03:43, 24 May 2020 (UTC)
:{{ping|GreenC}} This module is intended to serve a variety of use cases generically, so it's different than {{tl|NUMBEROF}}, but I added a "See also" link to that template, just in case. This module provides {{ml|Tabular data|wikitable}} for situations where the entire table is needed on a given page, as opposed to a lookup of a few values. That function could be made more flexible, along the lines of {{tl|Json2table}}, but I think ultimately any use case that requires looking up a lot of values from the same Commons table and including the results on the same page warrants a dedicated Lua module to build that entire portion of the page. Then caching wouldn't be so relevant, because the Commons table would only get loaded once anyways. – [[User:Mxn|Minh <span style="font-variant: small-caps;">Nguyễn</span>]] <sup>[[User talk:Mxn|<span style="display: inline-block;">💬</span>]]</sup> 22:44, 25 May 2020 (UTC)
|