Archy-X / AuraSkills

The ultra-versatile RPG skills plugin
https://aurelium.dev/auraskills
GNU General Public License v3.0
235 stars 88 forks source link

Optimize multiplier permission lookup #267

Closed ErikSzabo closed 4 months ago

ErikSzabo commented 4 months ago

If you use LuckPerms as the permission manager (which I assume most of the servers do), you can now use a cache for effective multiplier permissions. Cache will recalculate when user/group gets or loses permission. This happens async. Only the first call will cause a cache calculation sync.

For lookup times it is like ~17 times faster even for an average luckperms database.

Benchmark results

This benchmark shows the total time elapsed to calculate the multiplier.

This is with an avg permission database OG Method avg: 178,968 ns LP Hook avg: 10,230 ns

This is with a small permission database (OPs in discord) OG Method avg: 45,299 ns LP Hook avg: 8,629 ns

ErikSzabo commented 4 months ago

I'm still trying out stuff from the luckperms API to possible make this even faster, so I converted this to draft. I will convert it back when I'm finished with experimentation.

Archy-X commented 4 months ago

You don't need to add the dependency in build.gradle.kts in the bukkit module because it's already included in the common module.