Daniel Friesen wrote:
I believe we do locally (in-process) cache the preprocessor structure for pages and templates, so multiple use of the same template won't incur as much preprocessor work. But, the preprocessor parsing is usually one of the fastest parts of the whole parse.
I could swear we locally cache template wikitext, and save preprocessed data to the object cache. Least I think thats what I gathered last time I read the code.
~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name%5DYes
Yes. Calling a template twice will only fetch the text once, won't increase the 'used templates' counter... Preprocessing of wikitext over a threshold is cached serialized (it's easier to reprocess if it's too small).
On the original question: The tree will be reused, but it has to be expanded again. It's not clear that you gain by using a library since you will pay the library costs on all articles using it. Templates should be kept simple (yes, enwiki is particularly bad at that).
In early 2007, eswiki implemented a library template (Plantilla:Interproyecto) which was used for adding any interwikis to sister projects. It caused server problems and got disabled by the sysadmins.