Semi Protection

UESPWiki:Administrator Noticeboard/Archives/Templates and Performance

The UESPWiki – Your source for The Elder Scrolls since 1995
Jump to: navigation, search
This is an archive of past UESPWiki:Administrator Noticeboard discussions. Do not edit the contents of this page, except for maintenance such as updating links.

Templates and Performance

At the moment, templates are the performance burden of the site. However, I beleive we can clean some of these templates to gain some performance. For example, there are some templates which are only used as placeholders of other templates which are not used anywhere else, like Template:stub and [[Template:stub-mw]]. These templates may be joined into a single one to save the server from wasting resources by including another template. One notable template that calls many other templates is Template:NPC Summary, but I don't really know to what extent this can be flattened.

There are also templates which are just a redirect to other templates, like Template:Linkable Entry and Template:LE. These templates can be deleted and replaced by the root template, again avoiding the server from redirecting. In the particular case of LE, this is quite a drag, as it is usually used many times (dozens) in a single page. If shorthands are needed, there are a few other options: a) have NepheleBot replace shorthand templates with the root template every now and then; b) install some kind of hook to replace the code before saving the page; c) put a link to the root template in MediaWiki:Edittools.

Well, I hope I have drawn your attention, as I have seen this issue poping up in many places of the wiki, and I think it deserves discussing. These are my first ideas, but I hope you have some more. Any comments? --DrPhoton 08:55, 23 January 2008 (EST)

I've thought about template performance and while I haven't explicitly measured it I'm not sure its a major cause of the site performance issues. Unlogged users always see the cached version of a page so it doesn't matter how many templates the page has. Templates can slow down the display of an page to a logged in user (I think), or the first time the page is rendered, or if a commonly used template is changed.
Of course, having said that, I think it still might be worthwhile to look at any template optimizations that can be easily done. -- Daveh 09:27, 23 January 2008 (EST)
I'd agree that having templates redirecting to other templates isn't a great state of affairs and I'll also agree that there are a number of essentially useless templates around on the site. In terms of useless ones I think there are three categories:
  • Templates like SI, OB, BM etc are shortcuts that only spare keystrokes at the sake of hurting server performance and so should be removed.
  • Templates like [[Template:Quest Link Short|Quest Link Short]] and [[Template:Place Link Short|Place Link Short]], the latter of which has finally been proposed for deletion, which are at least as long as the commands they replace. There are dozens of templates around, and the rationale for many has been lost over time.
  • The last set is best represented by LE. Yes it's just a shortcut but it can have a huge effect in reducing the length of pages. We'd have to judge whether the performance benefit of smaller pages is offset by the reduced clarity of the name if we completely removed Linkable Entry.
I'll admit to being a bit over-keen to create new templates - everyone always likes to play with a new toy - but I don't think it's the new templates that are hurting performance. If that were true I'd expect to see the site slowdowns occur only when the processor usage is very high, and that's not happening. Even so, we may need to go through and look at each one and see if it's really necessary. That's a big job though. –RpehTCE 10:13, 23 January 2008 (EST)
I also don't think that templates are responsible for the site slowdowns and inaccessibility problems; my apologies if some of the comments that I've made have suggested otherwise. Furthermore, I think that templates are a very useful tool that should continue to be used widely on the site wherever appropriate. On the other hand, there are several specific bugs/limitations with templates that do cause problems, in particular on pages with large numbers of templates. And templates are not an efficient way to provide editing shortcuts. So I agree that it is useful to try to limit unnecessary template use. Some specific thoughts:
  • I agree that shortcuts like SI, etc. are problematic. On the other hand, I know that a fair number of editors have adopted these templates. One possible compromise with these templates is to keep the templates in place and available for editors, but have NepheleBot periodically go through in off hours and expand the templates to the non-shortcut equivalents. It allows editors to have the convenience while eliminating any longterm impact on the server.
  • Templates like Quest Link Short really aren't needed any more; they were useful back when quest pages were on quests subpages (e.g, Oblivion:Quests/Find_the_Heir), but various rounds of reorganization have made them unnecessary. If anyone finds templates like these that are being used on more than a handful of pages, please add them to NepheleBot's list (at User talk:NepheleBot#Update Links) and the bot can clean them up very easily.
  • I'm not sure that there's any template overhead from template redirects. My understanding is that when the server sees LE on a page, it directly inserts the contents of Template:Linkable Entry, just as if Linkable Entry were being used on the page (note this is very different from nested templates, such as for example on Stub right now; this only applies when the template page is of the form #redirect [[Template:Linkable Entry]]). On the other hand, I don't know that the page length reduction caused by replacing Linkable Entry with LE has any benefits. That page length reduction is only relevant for the version of the page seen by wiki editors, so there's a small difference when an editor loads the page, and there's a space reduction somewhere deep in the database (and we're not short on disk space). The length of the HTML page is completely unaffected, and it's the length of the HTML page that has any impact on the site overall, in terms of the bandwidth needed every time a reader views the page. So in my opinion, the only advantage from templates such as LE is the editor shortcut (although the disadvantage is far less than that for other shortcuts such as SI).
  • NepheleBot has already finished cleaning up all of the stub, needs image, and cleanup templates. So now all that's needed is for someone to merge the namespace-specific text/images into the main template and prod the others.
  • I don't think the complexity of templates such as Template:NPC Summary is fundamentally a concern. The template is complex because it includes a lot of different features, and it calls other templates because those templates provide an efficient and/or standardized way to do certain tasks (e.g., to figure out what colour to use for each race). But given that the template is not used hundreds of times on a page, the complexity does not cause problems. Even on a page such Oblivion:Knights of the Nine, which was just changed to call NPC Summary nine separate times, the template parsing statistics are fine (Pre-expand include size: 469855 bytes; Post-expand include size: 91472 bytes; Maximum: 2097152 bytes. In other words, it's only 20% of the way to where problems start to occur). It's important with templates like these to use /Doc subpages, but I don't think we want to start sacrificing usefulness.
Overall, I think it's worth keeping our eyes open for cases where templates can be improved. But I don't know that we need to systematically go through and examine every template on the site. --NepheleTalk 13:21, 23 January 2008 (EST)
Well, it seems I misunderstood how templates work at the server side. As I understand it now, templates are rendered every time a new page cache is built, right? So, does this mean that they can have an impact on editing and previewing pages, and consequently on the server?
As far as templates redirects, I did a little test to check whether they have any impact. I open two edit windows with Morrowind:Base Weapons and on one of them I changed all LE by Linkable Entry. Then I previewed both edits and I haven't noticed any appreciable difference in the time they were redenred. I then changed the text on both pages a bit to force the server to build a new cache, and again no difference. So it seems redirects have no impact on the server.
I don't want to start a site-wide template optimization/revamping unless it's necesary. So if you think templates aren't a concern, let's just leave them alone (except for normal maintenance/cleanup), although. --DrPhoton 03:29, 24 January 2008 (EST)