Core Loot Manager DKP & EPGP & SK

Core Loot Manager DKP & EPGP & SK

1M Downloads

Optimize memory usage by proper caching

lantisnt opened this issue ยท 5 comments

commented

As per discussion with QartemisT some of our use cases are not optimal. Need to do some changes:

  • Cache global wow api functions (that originate from _G) which leads to big cpu usage overhead
  • Stop caching private fields originating from CLM which lead to small memory overhead
commented

My preliminary benchmarking suggests this is negligible; testing 100k accesses over 100 times... shows no gain in the caching you describe.

Mostly in nested calls that are called very often we get a benefit from local caching inside the function not the file.
image

This screenshot shows times for different test cases; it also shows no difference in local vs global.
These numbers are the same after seeding _G with 100.000 variables.

Test code: https://gist.github.com/SamMousa/a0c44317833540d2172033b9c2b02e2f

commented

Gains indeed seem insignificant. Instead I will work towards unifying the code across addon

commented

If you take a look at other addons you will notice it needs to be done per lua file as all global are stored in _G which can end up with about 30000 elements to lookup. Thus we should do what other devs do: local x = x

commented

They are implemented as hash tables, lookups are constant time. Have you benchmarked this?

commented

This should be abstracted, so it is reusable for multiple addons. Doing so will make it have a bigger impact as well