ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   PTS issue, or? (https://www.esoui.com/forums/showthread.php?t=5050)

Fyrakin 08/30/15 10:35 AM

Quote:

Originally Posted by merlight (Post 23019)
I tried to explain that there's no reason to compute the root if you only need it for comparison against some distance threshold. Additionally, each sub-expression should only be computed once -- it's both more efficient and readable.

Like this function, it does way too many avoidable table lookups and an unnecessary sqrt:
Lua Code:
  1. local function IsCoordinateInRange(x, y)
  2.     if not FyrMM.currentMap.TrueMapSize or not FyrMM.currentMap.PlayerNX or not FyrMM.SV.CustomPinViewRange or not FyrMM.SV.ViewRangeFiltering then return true end
  3.     return FyrMM.currentMap.TrueMapSize * math.sqrt((x-FyrMM.currentMap.PlayerNX)*(x-FyrMM.currentMap.PlayerNX)+(y-FyrMM.currentMap.PlayerNY)*(y-FyrMM.currentMap.PlayerNY)) <= FyrMM.SV.CustomPinViewRange
  4. end

Lua Code:
  1. -- this is used so heavily that I'd localize it at the file level
  2. local g_currentMap = FyrMM.currentMap
  3.  
  4. local function IsCoordinateInRange(x, y)
  5.     local mapSize = g_currentMap.TrueMapSize
  6.     local nx = g_currentMap.PlayerNX
  7.     local pinViewRange = FyrMM.SV.CustomPinViewRange
  8.     if not (mapSize and nx and pinViewRange) then return true end
  9.  
  10.     local dx = x - nx
  11.     local dy = y - g_currentMap.PlayerNY
  12.     return (dx * dx + dy * dy) * mapSize * mapSize <= pinViewRange * pinViewRange
  13. end

It is a very fast changing environment, btw this particular function works fine no difference between live and pts. I made heavy changes during past week meantime testing it against pts and speeds are looking acceptable. Though it runs much smoother on live.

PS I also have noticed a faster garbage collection growth while using local variables. This is very worrying.

Sasky 08/30/15 12:29 PM

Quote:

Originally Posted by Fyrakin (Post 23020)
It is a very fast changing environment, btw this particular function works fine no difference between live and pts. I made heavy changes during past week meantime testing it against pts and speeds are looking acceptable. Though it runs much smoother on live.

PS I also have noticed a faster garbage collection growth while using local variables. This is very worrying.

What merlight is trying to say is that finding the square root is a computationally expensive operation and should be avoided if at all possible. If sqrt( A ) < sqrt( B ), then A < B for distances.

I'd look at what else you're doing in the function because local variables by themselves won't noticeably increase GC time ( http://lua-users.org/wiki/OptimisingGarbageCollection ). In fact, it's generally an optimization to copy over to local from a global table, especially if you're going to access it frequently. (http://lua-users.org/wiki/OptimisingUsingLocalVariables)

For example, looking up "FyrMM.currentMap.TrueMapSize" actually needs 3 table lookups: FyrMM in the Global table, currentMap in FyrMM, and TrueMapSize in currentMap. Bringing it to a local variable caches it so that when you access it the second or third time it's already present.

Fyrakin 08/30/15 07:46 PM

Quote:

Originally Posted by Sasky (Post 23022)
What merlight is trying to say is that finding the square root is a computationally expensive operation and should be avoided if at all possible. If sqrt( A ) < sqrt( B ), then A < B for distances.

I'd look at what else you're doing in the function because local variables by themselves won't noticeably increase GC time ( http://lua-users.org/wiki/OptimisingGarbageCollection ). In fact, it's generally an optimization to copy over to local from a global table, especially if you're going to access it frequently. (http://lua-users.org/wiki/OptimisingUsingLocalVariables)

For example, looking up "FyrMM.currentMap.TrueMapSize" actually needs 3 table lookups: FyrMM in the Global table, currentMap in FyrMM, and TrueMapSize in currentMap. Bringing it to a local variable caches it so that when you access it the second or third time it's already present.

I know ;), I'm not new into LUA.

merlight 08/31/15 10:11 AM

Quote:

Originally Posted by ZOS_ChipHilseberg (Post 22974)
Saving performance took a hit because of some changes over the past six months (introducing an intermediate buffer), but we've restored the performance internally and will be fixing that before 1.7 launches. Performance of the VM itself is not a known issue however. We have not noticed any changes to the performance of the stock UI. If you learn more, please let us know.

I wonder... we refer to 1.7 because we're used to counting big updates since launch, of which there were six. And then marketing came with 2.0 -- which amounted to unlocking the Crown Store -- as if that update was bigger than all before it :D I find it somewhat comforting that you still count updates and not items-of-the-month ;)

QuadroTony 09/21/15 11:51 AM

2.1.7
Quote:

Fixed an issue where using /reloadui would occasionally freeze your screen for up to a minute before entering the loading screen.
looks like fixed?


All times are GMT -6. The time now is 07:22 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI