I'm writing a mod that allows configurable, specialized buff/debuff tracking on various targets. Currently, it listens for events like PLAYER_TARGET_CHANGED, UNIT_AURA, etc to re-scan all auras on affected units (via UnitAura()) and update displays.
I've found a number of individual posts over the last few years that comment on the performance of Unit[Buff|Debuff|Aura](), usually when used by raid frames addons (ag_UF, OpenRDX, others). In most cases, these posts were about performance problems related to excessive Unit[Buff|Debuff|Aura]() calls, and the somewhat complicated optimizations that were developed to avoid them.
I'm wondering if this is a situation ripe for a library -- something like a LibUnitAura. This library could be used by any addon that wants notification of particular categories of aura changes (i.e. "I want to track buffs on the player"; "I want to track debuffs on the target"; "I want to track debuffs on any raid member"; etc).
Does such a library already exist? I wasn't able to find anything on the forums but maybe my search-foo was not strong.
If not, does somebody want to develop one? =D We might be able to use an existing unitframes addon's optimized code as a starting point (I recall some comment that OpenRDX had implemented some kind of aura cache to improve performance...)
The way I'm envisioning this, addons would register with the library to receive the specific updates they need, and the library would handle all the UnitAura() calls necessary to satisfy the needs of those addons. By having addons query the library, they can avoid doing their own own UnitAura() calls (and the necessary optimizations) for a net performance gain and addon code complexity reduction.
The library could then offer an improved API to the vanilla UnitAura(), and could get pretty fancy on an optimization front, and abstract that complexity away from the addons. For example:
- dispatch improved UNIT_AURA-type events that include, for example, the name or aura-index of the aura gained, lost or changed, so that addons only have to update the portions of their displays relevant to that particular aura (currently they generally have to reset all auras to "missing", re-scan all auras to determine which are still present, and then either manually determine what really changed or else re-draw everything, which is slow)
- listen only for events that affect a unitid that somebody cares about (if somebody wants to track "target" then the library needs to listen for PLAYER_TARGET_CHANGED; if the only listeners are for "player" then we don't)
- scan only aura types that somebody cares about (if some addons want player buffs but nobody cares about player debuffs, then we only have to do UnitAura("player",n,"HELPFUL"), no need for a "HARMFUL" loop)
- detect unitid changes that don't require a full aura re-scan (if PLAYER_TARGET_CHANGED happens, and UnitIsUnit("target","focus"), and we already have an aura cache for "focus", we can just use that cache rather than re-scanning "target")
- allow customizable update intervals (if an addon only needs 1s updates, hold them in a queue ala AceBucket and dispatch all changes at once; if an addon really wants realtime updates, we can do that too, and still benefit from optimizations like the above "new-target-is-already-cached-under-another-unitid")
Thoughts? Suggestions? Volunteers? I'm certainly willing to help, and might try doing it myself if nobody has picked up the idea when I finish with my current project.
I created my own LibAura library (still work in progress) that is providing aura information for my addon. It currently supports aura's on units, spell cooldowns, Totems, Weapon Enchantments and some others that are still not available atm.
The code is not yet optimal and there are a few small bugs that need to be tracked down. But I'm interested in a general aura library that can be used by multiple addons. And I'm willing to share code and help out.
It's a hilarious coincidence that you necro'd this thread at just this moment, because just a few weeks ago I picked up my old code again and have been fleshing it out. I think mine is almost usable, but I'd be happy to collaborate. The lib you linked to looks interesting too, I'll have a look at how it does things.
Excelly I saw after my post that it was a 2 year old thread and was already regretting for bumping such an old post. I'll be online tonight (the Netherlands here) in #wowace/#wowuidev/#curseforge with the name Nexiuz. Not sure, I though I saw you there also a few time. We can have a chat maybe there.