04-29-18, 05:54 AM | #1 |
Wraper functions for 8.0.1 spell/aura changes
I have set of functions to wrap changes without no need to modify old code for transcending period in addon development. It allows still use code in 7.3 and 8.x. Just replace P. with your add-on name and then inlude at start of your code:
Lua Code:
If you want to use GetSpellInfo without need to worry about client version. Here are wrappers Lua Code:
Last edited by Edik : 04-30-18 at 11:58 PM. |
|
04-29-18, 04:08 PM | #2 |
From the limited tests I've done with cache tables (for UnitAura) it wasn't worth it, ie. the overhead of creating and copying tables was worse than just looping every time. (both from CPU and garbage being created perspectives)
Though my tests were done on 7.3 since I don't have access to beta yet. |
|
04-30-18, 05:21 AM | #3 |
In 7.3 you won't need any caching. In 8.x is quering Aura by name completely removed. So if you have mutiple checks in single line I guess caching is worth to try. If you do by aura index from 1 to 40 old fashioned way you won't need to cache. Just imagine if you have this in your old code.
Lua Code:
I had my wrappers a small glitch I did fix it original post. Last edited by Edik : 04-30-18 at 05:29 AM. |
|
04-30-18, 06:55 AM | #4 |
Your aura caching is utterly inefficient and in its current form actually useless. What is the point in hitting a cache which invalidates itself every 1/10 of a second?
|
|
04-30-18, 08:42 AM | #5 | |
@Rainrider
Just for info. This comes off pretty rude.
__________________
| Simple is beautiful. | WoWI AddOns | GitHub | Zork (WoW)
|
||
04-30-18, 10:17 AM | #6 |
04-30-18, 12:28 PM | #7 | |
Also UnitAura doesn't support querying by spellid in either 7.3 or 8.x, the second argument if numeric is just an index. Last edited by boomboo : 04-30-18 at 12:35 PM. |
||
04-30-18, 03:34 PM | #8 |
I used this for testing:
lua Code:
The changes I made to Edik's code were: 1. removed the toc check (tested on beta only) 2. local index, _, filter = select(1,...) - > local index, filter = select(1,...) 3. cache[string.lower(name)] = table.copy(retTable) -> cache[string.lower(name)] = retTable On average the cached version is 4 times slower than with no caching. The test is not fair at all as it does not compare only the caching! The aim here is just to provide a rough estimation. Beware that GetTime() is cached by the client. This has side effects on Edik's implementation as well. The GetAura function can be optimized further. Please do not take the results as a contra cache statement. Caching may prove useful, but this depends a lot on the use case and the implementation. |
|
04-30-18, 04:05 PM | #9 |
It's not especially surprising since UnitAura is implemented in C (I presume), and might have it's own caching or optimizations. Adding stuff on top of it in lua doesn't help.
The best way to work around it is to probably reverse the loops for 8.x ie. instead of doing: Code:
for list_of_spells_I_care_about { for 1, N { name, ... = UnitAura(, i, ) if(name == list_of_spells_I_care_about[i]) do_whatever() } } Code:
local list_of_spells_I_care_about_lookup_table for 1, N { name, ... = UnitAura(, i, ) if(list_of_spells_I_care_about_lookup_table[name]) do_whatever() } Last edited by boomboo : 04-30-18 at 04:12 PM. |
|
04-30-18, 07:43 PM | #10 |
This is what I've used and I'm quite happy with the result, for multi-checks. It's a bit much overhead for single checks, though. I haven't decided if I prefer an overloaded version or just a different call.
__________________
Addons ∙ Executive Assistant User Configurable To-Do List ∙ Legible Mail Choose the Font for Your Mail ∙ |
|
04-30-18, 11:29 PM | #11 |
I must agree with most notes here. I found falw in my code. In fact it didn't cahe at all if query didn't hit exactly same aura. I fix it by:
Lua Code:
now it is really effective and overhead is small if multiple aura checks by name are done in one cycle (in split .1s). Keep in mind these wrappers are just for time period when code need to be 7.x compatible and you want to do just small or none changes for testing in 8.x. These functions aren't permanent for 8.x. I'm pretty sure that someone come with new UnitAUra, UnitBuff and UnitDebuff for quering aura by Name. BTW someone told about UnitAura doesn't support query by Name in 7.x I must disagree it does support. Form is UnitAura(unit,name[,[nameSubtext][,filter]]). Last edited by Edik : 04-30-18 at 11:57 PM. |
|
04-30-18, 11:39 PM | #12 |
I agree. GetTime() changing every frame update. When you have low FPS it could change only few times per second. But auras change few times per second as well if you care just about aura existence not about startTime, endTime is fine. That was target for these wrappers, just make code works at least in 8.x and do some backward compatibility.
Last edited by Edik : 04-30-18 at 11:59 PM. |
|
05-01-18, 07:17 AM | #13 | ||
From my perspective a wrapper should be just that and not a cache on top of it. The interesting part is the gap in performance between best and worst case and it makes it clear how inefficient your UnitAura calls are. You pack the results of UnitAura in a table and unpack it later for return. You also have all the table look-ups in between. What is the benefit from that? Also lua Code:
is the same as lua Code:
but without the added function call. |
|||
05-01-18, 05:51 PM | #14 | |
In most other cases if you filter correctly (eg. use HARMFUL|PLAYER) the number of auras should be small enough to iterate over so that the overhead of creating / destroying the cache is worse than looping. |
||
05-02-18, 04:16 AM | #15 |
If you have a case where you query information about multiple auras upon every UNIT_AURA then a cache is useful. Basically you refresh your cache once on UNIT_AURA and all your queries always hit the cache. If your cache structure is shallow enough, the table look-ups will be faster then calling UnitAura. One problem with Edik's implementation is that auras are re-iterated on cache misses and the new iteration is also a miss. If you can't trust the cache, then there is no point in it.
|
|
WoWInterface » PTR » PTR General Discussion » Wraper functions for 8.0.1 spell/aura changes |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|