Slothpala / RaidFrameSettings

GNU General Public License v2.0
4 stars 4 forks source link

Applying Coroutines to Show/Hide CDT and Aura Frames #53

Closed excorp closed 2 months ago

excorp commented 2 months ago

This is not real PR. I just want to share what I've been testing.

I tested applying a coroutine to the cooldown timer and show/hide of the aura frame to reduce lag.

The results were that the Cooldown Timer had a big effect, but the show/hide in aura, it actually decreased the FPS even more. However, I'm hopeful that the lag was reduced at the sacrifice of more frames.

When applying the coroutine to the Cooldown Timer, I think it would be more effective to have it pause for 0.1~0.5 seconds after looping once and then loop again.

  1. https://youtu.be/bZSY3udZ1Sc - 19.6ms | Apply coroutines to CDTs
  2. https://youtu.be/OF8lcL6N7WY - 24.3ms | Apply coroutines to CDTs and aura queue
  3. https://youtu.be/5F1bgKxm0bE - 55.54ms | Original RFS
  4. https://youtu.be/ss8-lFE6e6s - 57.3ms | Apply coroutines to aura queue

Oh, by the way, to create an extreme environment, I tested with 30 buffs and 15 debuffs in each frame. This would never happen in the real world.

Slothpala commented 2 months ago

`local interval = 0.5 local time_since_last_upate = 0

local function updateFontStrings(_, elapsed) time_since_last_upate = time_since_last_upate + elapsed if time_since_last_upate >= interval then time_since_last_upate = 0 local currentTime = GetTime() for Cooldown in next, CooldownQueue do local time = ( Cooldown:GetCooldownTimes() + Cooldown:GetCooldownDuration() ) / 1000 local left = time - currentTime if left <= 0 then CooldownQueue[Cooldown] = nil end Cooldown._rfs_cd_text:SetText(getTimerText(left)) end if next(CooldownQueue) == nil then CooldownOnUpdateFrame:SetScript("OnUpdate", nil) time_since_last_upate = 0 return end end end`

Slothpala commented 2 months ago

Throttling may be a better way to go than coroutines.

excorp commented 2 months ago

I've said it before, but I'm a novice at addon development. I don't even know lua very well. I found out about coroutines by some chance, and I thought that using them to time-slice would prevent one routine from taking up a lot of CPU time, and that would reduce the freezing (lag), so I tried it.

But I think the cooldown timer won't take up a lot of CPU time, so just giving it an interval like you said should be enough.

I just wanted to share that I tested this! 😃

Slothpala commented 2 months ago

Yeah, it's fun to play around with :D I've read that corotinues in wow lua use a lot of memory, but I haven't tested it.

I also measured some extremely high CPU usage (with the AddOns CPU Usage and Addon Usage add-ons) when in raid (Amirdrassil), but the FPS drop was only 3 to 5 fps and no noticeable lag on either my low spec Macbook or my gaming PC.

So I made a small test addon that just hooks into the functions that RFS uses and does nothing but call a function that adds two numbers. And I also got this extreme CPU usage. So I am not sure if these addons (or rather the functions they call to get their data) are really suitable for measuring performance. My suspicion is that some of the work done by the built-in Blizzard functions is being blamed on the addon. The strange thing though is that this only happens when in the raid. In epic bgs with 40 man in my group and all modules enabled the usage is around 30 to 40ms which sounds about right for what the addon does.

Slothpala commented 2 months ago

local function add_two_numbers(nbr1, nbr2) local result = nbr1 + nbr2 return result end

hooksecurefunc("CompactUnitFrame_UpdateAuras", function () local result = add_two_numbers(8, 9) end)

hooksecurefunc("CompactUnitFrame_HideAllBuffs", function () local result = add_two_numbers(4, 9) end)

hooksecurefunc("CompactUnitFrame_HideAllDebuffs", function () local result = add_two_numbers(2, 3) end)

hooksecurefunc("DefaultCompactUnitFrameSetup", function () local result = add_two_numbers(4, 7) end)

hooksecurefunc("CompactUnitFrame_UtilSetBuff", function () local result = add_two_numbers(1, 4) end)

hooksecurefunc("CompactUnitFrame_UtilSetDebuff", function () local result = add_two_numbers(9, 2) end)

Slothpala commented 2 months ago

With this addon I get 200 to 400 ms of addon usage, which sounds a bit high for adding some numbers. So I am a bit confused, is securehooking just that expensive or is the work of Blizzard's own functions measured when hooking.

excorp commented 2 months ago

It's amazing how simply adding two numbers can increase by 200-400ms. I'm closing this PR anyway