Media Wiki - Variables Extension?

Jump to: navigation, search

As a practice, we frequently do "double varpulls" in our templates, once to check "Does the page have this key/value defined?" and then a second to act on that value. In order to save #varpulls, which I believe we've said are relatively expensive, I'd like to toss out the suggestion for bringing in the Variables Extension or something which provides similar functionality. Here's an example page where it could make a difference: Item Row Template. In this template, which is used on our most painful pages, we make the following pulls:

  1. color
  2. attack
  3. defense
  4. attack
  5. defense
  6. procRate
  7. procRate
  8. procDmgCap
  9. procDmgCap
  10. procDmgMin
  11. procRate
  12. procRate
  13. procDmgMin
  14. ability
  15. obtained

and we also calculate procRate / 100 * procDmgMin twice. Using variables, we could reduce this 15 to 8 and remove one of the duplicate calculations, which I imagine would help.

--doomcat

Doomcat (talk)12:49, 23 April 2014

the new version of #varpull was caching information. unfortunately there is a bug somewhere and i had to revert it. i was not checking the cached value to see if it was still valid.

I evaluated Variables extension. It can be installed, but it does not solve the problem (which #varpull does solve) and requires more transclusion and parsing than #varpull does to achieve the same result so Variables is less efficient at the task. Also we have to redo every item page to work with Variables. So that is some major negatives.

The use case of #varpull is this:

  1. Data exists in some article such as Game/Item/Awesome_Sword
  2. We want to generate a page which contains all the swords e.g. Game/Swords
  3. Game/Swords must query Game/Item/Awesome_Sword and all other swords to get the data

For Variables comparison of this task: See Is_there_a_way_to_get_a_value_from_one_page_from_another_page?

Where #varpull excels is getting this specific data. Where it fails is having to requery the same data repeatedly. Not a huge problem, but a solvable one using memcached, which is far superior to any transclusion. None of the ready made solutions offer the same functionality.

I will fix the new version of varpull and all will be good to make sure that it refreshes the cache when it has gone stale. Till then reverted to tried and true version that works.

I will install Variables as well for playing with, but I have a feeling that we will not get significant gains except when fields that are calculated are the same in an "ItemRow" template. Be warned there is some over head there as well.

Zoycite (talk)13:54, 23 April 2014
 

Variables is now installed

Zoycite (talk)14:21, 23 April 2014

I think I might have been a little unclear. I never intended variables to replace #varpull, as #varpull does what it does very well. I was just hoping to reduce the overhead of LotS' intense item list pages which have recently been acting up a little more than normal. Sorry for the confusion, and I hope I wasn't offensive.

--doomcat

Doomcat (talk)21:35, 23 April 2014

not offensive, my main concern is to just avoid installing things without a purpose. if we have a reason for extension that will do things we want -> install.

I could see defining a calculated value variable potentially if that value is needed in other calculations. There is a minor gain there.

I guess i was confused as to the intent of the extension:Variables somewhat. i thought we were trying to do something that it does not do so was stating that it wont really solve the primary problem that varpull solves.

I need to fix the error in the new version of varpull. The problem could have been hardware related i am still researching what went on. But I should still be able to revert to uncached behavior if i can detect when the value returned by the cache is invalid. Also i can likely improve the cached data behavior.

Zoycite (talk)23:07, 23 April 2014

I took a pass at simply extracting out duplicated varpulls from http://zoywiki.com/index.php?title=Template:LotS/ItemRow into variables, like {{#vardefine:procRate|{{#varpull:LotS/{{{1}}}|LotS Item|procRate}}}}. I don't know if you have any profiling tools to tell us if that was an improvement. A good place to check would be to see if the creation time of http://zoywiki.com/LotS/items/Helmet has decreased at all (I believe Helmets is our biggest page that uses that template).

--doomcat

Doomcat (talk)06:17, 24 April 2014