Jump to content

User:Dragons flight/Lua performance

From Wikipedia, the free encyclopedia

Since initial deployment, a little more than a month ago, enwiki has converted several dozen templates to use Lua (e.g. Category:Lua-based templates). The following is a summary of real world performance testing conducted on enwiki to compare the time required for rendering both the old and new versions.

Testing procedure

[edit]

For each template reported below, a test page was generated that called the template repeatedly (typically a few hundred times), using varied input taken from either lists of test cases or real world pages. These pages were loaded using Mediawiki's "preview" function and the time required was measured via the "served by" comment in the HTML source of the rendered preview. This previewing was repeated five times and the results averaged. In addition, the time required to preview a blank page was subtracted from the total to isolate the effect of the templates. Lastly, the total time was divided by the number of template iterations to derive a time per iteration. This procedure was repeated with both old and new versions of the template to measure the impact of introducing Lua.

Updated: Tests were rerun and numbers updated May 18, 2013.

Results

[edit]
Template Purpose Time per iteration (ms) Iterations per Second
Old version New version Change Old version New version Change
{{rnd}} Number formatting 12.7 3.9 -69% 78.7 254.8 +223%
{{precision}} Number formatting 11.6 3.5 -70% 85.9 289.7 +237%
{{max}} Maximum value in list 5.7 2.4 -56% 85.9 289.7 +128%
{{str len}} String length 20.4 2.6 -87% 48.9 375.4 +667%
{{str find}} Find substring 158.5 2.9 -98% 6.3 347.2 +5402%
{{coord}} Coordinate rendering 69.3 11.4[1] -83% 14.4 87.4 +505%
{{weather box}}[2] Climate data display 8536.9 455.5 -95% 0.1 2.1 +1774%
{{navbox}} Navigational box 116.9 51.1 -56% 8.5 19.5 +129%
{{convert}}[3] Unit conversion 61.8 4.7 -92% 16.1 215.0 +1227%
{{citation}} Citation formatting 58.9 7.7 -87% 17.0 129.4 +661%
  1. ^ Approximately 5 ms is due to the {{#coordinates}} extension that stores geo data into the database
  2. ^ Only 3 iterations were used in testing due to the long runtime
  3. ^ The convert Lua module has not yet been deployed. This test was done on the current development version.

In addition, testing done with a dummy Lua module that takes one parameter and does nothing estimated that the Mediawiki overhead per Lua #invoke call is approximately 2.0 ms. Consequently, for functions like {{rnd}} and {{str find}}, a majority of the execution time is actually devoted to the parser overhead associated with launching a Lua #invoke call. For the important case of citation templates, the overhead appears to be approximately 25% of the run time.