Template talk:W-color

performance hit with many template instances?
I have just tried to include this and all similar templates into Skills by capture location (Nightfall), and I have found myself unable to. There are exactly 460 occurences of the profession colors; I have replaced all of them with their respective color templates.

I have separated the code of that page with a shifting opening nowiki-tag (plus table closing) and a closing tag at the end of the page to make sure that the inclusion of the templates are causing the performance hit. Measurements showed:

at 200 inclusions of the various x-color templates, the waiting time until the preview page was served was 11 seconds.

at 300, it was 20-23 seconds.

at 350, it was 33 seconds

at 400 and above, the preview didn't show at all, giving only a blank page.

These values have been measured repeatedly and were consistent to 1 or 2 seconds at most. Can anyone confirm these results (at least proportionally) or is the problem on my side? --RolandOfGilead 17:54, 29 January 2007 (CST)


 * Can you save the test page to a page in your user-space, so we can try viewing without needing to re-create? --- Barek (talk • contribs) - 17:56, 29 January 2007 (CST)
 * Oh, also, what OS, browser (and version), and internet connection type/speed are you using? --- Barek (talk • contribs) - 18:02, 29 January 2007 (CST)


 * It would be a shame if using too many instances of a template was impossible. The article is rather large, would splitting it up into sub-articles be sensible? Then each sub-article could be saved individually. Of course, this might not solve the problem, and even if it did it might not be a good idea to split an article up just so we can use some templates in it!  &lt;LordBiro&gt;/&lt;Talk&gt; 18:17, 29 January 2007 (CST)
 * Opera 9.02, Win XP Pro SP2, connection DSL: 2048 up, 192 down, ping to gw.gamewikis.org = 172 ms, User:RolandOfGilead/TemplateTest --RolandOfGilead 18:18, 29 January 2007 (CST)
 * I have just tested with IE 6.0, and while that outdated POS doesn't give a time display, it has about the same delay as with Opera. --RolandOfGilead 18:22, 29 January 2007 (CST)


 * I can check other browsers on XP when I get home; but from here, on Win 2000 sp4, using IE6, tests 1, 2, and 3 open instantly, no noticeable lag. But, test 4 refuses to open at all. --- Barek (talk • contribs) - 18:23, 29 January 2007 (CST)
 * Have you tried _editing_ too? Is there a lag if you request the preview window or when you save the page? --RolandOfGilead 18:24, 29 January 2007 (CST)


 * Interesting - just viewing is instant. But, in edit mode, test 1 took 3 seconds, test 2 took 9 seconds, test 3 took 16 seconds, and test 4 thought about it for 15 seconds then when to a blank screen. --- Barek (talk • contribs) - 18:30, 29 January 2007 (CST)
 * Okay, so it seems our results are proportional. Do you propose further testing? edit: The discrepancies in our absolute values might be due to different upload speed; what's your upstream? --RolandOfGilead 18:32, 29 January 2007 (CST)
 * From here, no idea. I can do better testing from home tonight. --- Barek (talk • contribs) - 18:38, 29 January 2007 (CST)
 * Just a thought - As it's only in edit, and not view - the easiest work-around until a solution can be found may be to do like LordBiro mentioned - ie: break the page into multiple subpages, that all get displayed together via inclusions on a master page. Not sure if it will solve the problem, as the resulting page would still have 400+ inclusions of the template - but worth a try.  --- Barek (talk • contribs) - 18:40, 29 January 2007 (CST)


 * Nope. It seemed to be marginally faster, but at 350 includes it was about 30 seconds, and 400 still refused to load. See TemplateTest/9. --RolandOfGilead 18:59, 29 January 2007 (CST)


 * I have to go to bed now, but I've just been talking with Fyren who suggested just using CSS classes instead of templates. There would be less flexibility in the unusual cases, but I think if we're going to have problems implementing this system then it would be better to switch to CSS now rather than later when we find an even bigger article with more instances. :/  &lt;LordBiro&gt;/&lt;Talk&gt; 18:43, 29 January 2007 (CST)
 * Changing the profession colors won't quite be wiki-easy then I guess, but still easier than wading through each and every article to replace instances of a plain color word, or having lots of articles that lag behind a color change. If someone really wants the official colors for something special and isolated, the templates can stay as well. It's just up to the editors to prevent build-up of more than about 200-300 total templates per page. Considering the technical limitations, that's the best we can currently get it seems. --RolandOfGilead 18:59, 29 January 2007 (CST)
 * Well, CSS appears to work on a small scale in User:LordBiro/Profession colours. I need to take care of some things IRL, but I suppose the next step is to test it in a large list now just to be sure. --- Barek (talk • contribs) - 19:08, 29 January 2007 (CST)


 * I'm going to bed now, but this CSS will only be useful on pages like Elite skills list, where each cell is a different position. There's probably a better way of using it on Skill Quests, but I'm not 100% certain. Anyway, night :) wub!  &lt;LordBiro&gt;/&lt;Talk&gt; 19:13, 29 January 2007 (CST)
 * Using CSS, I think we'll be better off going back to the formatting of class = "W-background", "W-border", etc. It loses the flexibility that we gained with the template - but in order to make it work in all tables, I think this'll be the only option. --- Barek (talk • contribs) - 19:21, 29 January 2007 (CST)
 * The tests so far have been using "background", which as the template is currently written, calls itself. I wonder if that's the root of the problem.  Reverting to an earlier version to see if it resolves the issue. --- Barek (talk • contribs) - 19:30, 29 January 2007 (CST)
 * Nevermind - it looks like RolandOfGilead had the same thought and is already testing it. Be back in an hour or two or three ...  --- Barek (talk • contribs) - 19:34, 29 January 2007 (CST)
 * I just couldn't stay away - had to see what happenned. That did it for me, removing where the templates called itself and now the edits even for 400+ calls works for me instantly. --- Barek (talk • contribs) - 19:44, 29 January 2007 (CST)
 * Yes, great minds, you know ;) Anyway, the problem seems to have been the recursive template call indeed, effectively doubling the number of templates whenever "background" or "border" is provided as argument, and on invalid arguments too, probably. I haven't tested the maximum of these optimised templates, but 460 were served in about 10 seconds (TemplateTest/14), which sounds acceptable to me. --RolandOfGilead 19:47, 29 January 2007 (CST)


 * Update: TemplateTest/9 has 1000 instances of the x-color templates, and serves the preview page in 24 seconds. I think it's quite safe to say that a switch to CSS is not necessary if we avoid recursive templates, no matter how nice they may look in theory. Right Biro? ;) --RolandOfGilead 19:52, 29 January 2007 (CST)