Optimizing WeakAuras.NewDisplayButton
emptyrivers opened this issue ยท 3 comments
It calls ScanForloads. Why does it do that?
ScanForLoads is hilariously expensive.
The update thread used in Transmission.lua calls this for each installed aura. This is possibly the reason that the whole thing is so damn slow sometimes.
So, yeah, I hijacked the Profiling systems to also record the amount of time each Weakauras.SomeFunction
executes. Then I ran an update on this aura, which causes a massive slowdown. The results aren't perfect (times over 100%? I probably screwed something up), but check it out:
WeakAuras EXPERIMENTAL Profiling Data:
Total time: 31975.82ms
Time inside WA: ERROR: count is not zero: 1
Time inside WA: 14367.66ms
% Time spent inside WA: 44.93
Systems:
function 20825.66ms, 144.95%
text 189.71ms, 1.32%
dynamicgroup 122.54ms, 0.85%
load 38.94ms, 0.27%
animations 7.07ms, 0.05%
custom text - every frame update 3.11ms, 0.02%
generictrigger COMBAT_LOG_EVENT_UNFILTERED 0.88ms, 0.01%
bufftrigger2 - multi 0.64ms, 0.00%
generictrigger cd tracking 0.30ms, 0.00%
bufftrigger2 0.13ms, 0.00%
generictrigger NAME_PLATE_UNIT_ADDED 0.05ms, 0.00%
generictrigger NAME_PLATE_UNIT_REMOVED 0.04ms, 0.00%
sound 0.03ms, 0.00%
generictrigger UNIT_AURA 0.01ms, 0.00%
bufftrigger ERROR: count is not zero: 1
bufftrigger 0.00ms, 0.00%
<snip the aura payload>
Functions:
Total time attributed to functions:
NewDisplayButton 13947.53ms, 4833.21%
SortDisplayButtons 11638.35ms, 4033.01%
ScanForLoads 6502.43ms, 2253.27%
afterScanForLoads 5712.21ms, 1979.44%
Update 4093.32ms, 1418.45%
DeleteOption 3569.85ms, 1237.05%
ReloadTriggerOptions 1526.28ms, 528.90%
AddOption 1361.15ms, 471.68%
Add 1284.30ms, 445.05%
SetRegion 1129.75ms, 391.49%
PickDisplay 860.35ms, 298.14%
DoConfigUpdate 815.76ms, 282.68%
GetData 624.17ms, 216.29%
EnsureOptions 512.96ms, 177.76%
ReloadGroupRegionOptions 504.49ms, 174.82%
UpdateDisplayButton 470.31ms, 162.98%
CanHaveDuration 294.04ms, 101.89%
SetThumbnail 257.51ms, 89.23%
GetDisplayButton 232.82ms, 80.68%
IsOptionsOpen 225.61ms, 78.18%
TimerTick 218.09ms, 75.58%
EnsureDisplayButton 204.43ms, 70.84%
ConstructOptions 182.30ms, 63.17%
CheckNumericIds 181.52ms, 62.90%
DeepCopy 180.50ms, 62.55%
GetConditionOptions 157.71ms, 54.65%
IsAnimating 145.77ms, 50.51%
CollapseAllClones 133.47ms, 46.25%
GetOverlayInfo 123.13ms, 42.67%
ReplacePlaceHolders 109.88ms, 38.08%
ShowOptions 106.47ms, 36.90%
Delete 101.54ms, 35.19%
FixGroupChildrenOrderForGroup 96.13ms, 33.31%
AddAnimationOption 95.55ms, 33.11%
validate 95.20ms, 32.99%
ResumeAllDynamicGroups 93.30ms, 32.33%
Pause 89.28ms, 30.94%
PreAdd 75.66ms, 26.22%
PauseAllDynamicGroups 71.64ms, 24.83%
GetTriggerSystem 66.17ms, 22.93%
SetFrameLevel 60.32ms, 20.90%
AddCodeOption 58.26ms, 20.19%
AddActionOption 41.28ms, 14.31%
CheckTalentByIndex 25.63ms, 8.88%
GetTriggerConditions 24.35ms, 8.44%
ConstructFunction 23.01ms, 7.97%
GetRegion 17.97ms, 6.23%
PositionOptions 16.95ms, 5.87%
SetIconNames 15.18ms, 5.26%
SetIconName 13.76ms, 4.77%
ActivateAuraEnvironment 11.59ms, 4.02%
GetAuthorOptions 9.32ms, 3.23%
GetTriggerDescription 9.21ms, 3.19%
GetNameAndIcon 8.29ms, 2.87%
UpdateAnimations 8.17ms, 2.83%
CheckPvpTalentByIndex 7.96ms, 2.76%
AnchorFrame 6.24ms, 2.16%
UpdateCloneConfig 5.87ms, 2.04%
UnitPowerDisplayMod 3.58ms, 1.24%
UseUnitPowerThirdArg 3.49ms, 1.21%
Modernize 2.91ms, 1.01%
CanHaveClones 2.71ms, 0.94%
ConstructConditionFunction 2.61ms, 0.91%
GetProperties 2.15ms, 0.75%
LoadFunction 2.12ms, 0.73%
CancelAnimation 2.08ms, 0.72%
CanHaveTooltip 2.06ms, 0.71%
IsLoginFinished 1.85ms, 0.64%
BorderOptions 1.84ms, 0.64%
LoadEncounterInitScripts 1.78ms, 0.62%
ContainsCustomPlaceHolder 1.67ms, 0.58%
CanHaveAuto 1.42ms, 0.49%
CountWagoUpdates 1.14ms, 0.39%
Animate 1.05ms, 0.36%
UpdateGroupOrders 0.99ms, 0.34%
IsPaused 0.99ms, 0.34%
UpdateButtonsScroll 0.90ms, 0.31%
LoadCustomActionFunctions 0.89ms, 0.31%
UnregisterCustomTextUpdates 0.85ms, 0.30%
debug 0.84ms, 0.29%
GetGlobalConditions 0.75ms, 0.26%
GetTriggerStateForTrigger 0.73ms, 0.25%
ClearAuraEnvironment 0.68ms, 0.23%
IsOptionsProcessingPaused 0.67ms, 0.23%
CheckMPlusAffixIds 0.65ms, 0.22%
LoadConditionPropertyFunctions 0.59ms, 0.20%
OptionsFrame 0.39ms, 0.13%
IsDefinedByAddon 0.36ms, 0.12%
EnsureClone 0.33ms, 0.12%
DeleteAuraEnvironment 0.32ms, 0.11%
DeleteCollapsedData 0.28ms, 0.10%
CheckCooldownReady 0.28ms, 0.10%
UpdateCurrentInstanceType 0.28ms, 0.10%
GetItemCooldown 0.26ms, 0.09%
GetActiveConditions 0.26ms, 0.09%
UnregisterEveryFrameUpdate 0.25ms, 0.09%
GetFrameLevelFor 0.22ms, 0.08%
PerformActions 0.22ms, 0.08%
split 0.21ms, 0.07%
CheckSpellCooldows 0.19ms, 0.07%
GetSpellCooldownUnified 0.11ms, 0.04%
createSpinner 0.08ms, 0.03%
GetAdditionalProperties 0.07ms, 0.02%
SetImporting 0.05ms, 0.02%
CheckItemCooldowns 0.05ms, 0.02%
IsCollapsed 0.04ms, 0.01%
RefreshTooltipButtons 0.04ms, 0.01%
SetTextureOrAtlas 0.03ms, 0.01%
ParseNumber 0.02ms, 0.01%
IsPickedMultiple 0.02ms, 0.01%
CloseImportExport 0.01ms, 0.00%
LoadOptions 0.01ms, 0.00%
LockUpdateInfo 0.00ms, 0.00%
CheckItemSlotCooldowns 0.00ms, 0.00%
ReleaseClone 0.00ms, 0.00%
CheckRuneCooldown 0.00ms, 0.00%
IsImporting 0.00ms, 0.00%
The count not zero, means that somewhere you forgot to Stop the profiling of a system/aura.
As to why NewDisplayButton does that, it appears that ScanForLoads is needed so that the later call to SortDisplayButtons can sort the new button into the right place. Calling both of those functions per aura on importing is clearly not necessary, so feel free to optimize that.