SamSuka
WeakAuras
WeakAuras

patreon


Dynamic groups: Now 17% more dynamic!

Hey, this is EmptyRivers. 2.12 is almost out of beta testing, and should be available for a full release very soon. I want to talk a bit about the primary change which I made for this version, which is a rewrite and expansion of dynamic groups.

For a bit of background, WeakAuras dynamic groups have up to this point been pretty inefficient. Every time any child of a dynamic group is updated, then the entire dynamic group is rebuilt, almost from the ground up. This would also include any unloaded child of a dynamic group, so if a user created or imported a very large dynamic group like this one, then a lot of unnecessary work would occur. Then, it would sort the entire group that it just rebuilt, without taking advantage of the fact that usually, a dynamic group is close to being fully sorted already. Additionally, the layout code (the part which made the group control the positions of its children) was highly tangled, which made adding new layout options quite challenging.

2.12 solves this with 3 major changes:

  1. The internal data structures are not nearly so eager to rebuild themselves now, and will pretty much only do that when editing the group in the options panel. This helps solve the problem where lots of unloaded auras would make the dynamic group slow to operate, even when those unloaded auras aren't actually doing anything.
  2. The sorting algorithm was changed to insertion sort, instead of whatever the default sort algorithm is that lua provides. Of course, with a complexity of O(n^2), insertion sort is not the fastest sort in general (merge sort or quick sort are usually quicker on a random list bigger than ~10 items), but for our purposes it is ideal. In most cases, we will only want to resort the group when a child becomes visible, or when e.g. a buff is refreshed. So, nearly always we essentially have a fully sorted list and we wish to add one new element to it. This has a complexity of O(n), better than merge sort or quick sort's O(n*log n). This ability to very quickly sort lists which are only slightly perturbed makes insertion sort ideal for dynamic groups.
  3. The layout code was refactored to be less tangled. This is not a very large performance increase, but it does allow us to add new layout options much more easily. For example, a grid style layout is available in 2.12.0-beta5 and later.

I did a few quick profiles of WeakAuras with a large dynamic group in a raid encounter, and found that these changes reduce the time spent on updating dynamic groups from about 6% of the total CPU time that WeakAuras takes, to less than 1%. Hopefully this will lead to improvements for users in general, but of course it is always hard to predict how impactful optimizations are for everyone.

Another feature that I added is the ability to use custom functions for the Grow and Sort options. Detailed documentation for those can be found on our wiki.


More Creators