enjin / Enjin-Minecraft-Plugin

GNU General Public License v3.0
10 stars 10 forks source link

Performance issues on player login and quit #11

Closed olliestanley closed 5 years ago

olliestanley commented 5 years ago

It appears to me that the plugin sometimes causes performance issues for servers with large numbers of players on player joins and quits, as a result of this call (which is fired every PlayerLoginEvent and every PlayerQuitEvent):

https://github.com/enjin/Enjin-Minecraft-Plugin/blob/master/bukkit/src/main/java/com/enjin/bukkit/EnjinMinecraftPlugin.java#L308

Event listeners calling this: https://github.com/enjin/Enjin-Minecraft-Plugin/blob/master/bukkit/src/main/java/com/enjin/bukkit/listeners/ConnectionListener.java#L32 and https://github.com/enjin/Enjin-Minecraft-Plugin/blob/master/bukkit/src/main/java/com/enjin/bukkit/listeners/ConnectionListener.java#L73

Which writes the ranks configuration synchronously: https://github.com/enjin/Enjin-Minecraft-Plugin/blob/master/core/src/main/java/com/enjin/core/config/JsonConfig.java#L43

Possible fixes I can think of would include switching this to async, and/or switching ranks configuration file writes to be on a timer rather than every time a player joins or quits (reducing the frequency of the calls for servers with high player traffic).

Favorlock commented 5 years ago

Thank you for the report. I was aware that the rank update calls were a potential cause. I imagine some of the issues could be related to the permission plugin performance (e.g. if it's communicating with a database). I'll take a look when I can.

Favorlock commented 5 years ago

I have uploaded a new build at https://github.com/enjin/Enjin-Minecraft-Plugin/releases/tag/v3.5.10. I have refactored some of the references you mentioned to perform functions async where appropriate and config saving now runs on a 1 minute timer. Let me know how things work out for you. If I don't hear back within the week I'll assume things are working and will close the issue.