ItemJoin

ItemJoin

157k Downloads

Optimizations for ItemJoin::Event: PlayerGuard (PlayerMoveEvent)

mibby opened this issue ยท 2 comments

commented

Tuinity dev 328 (Paper 1.16.1)
https://github.com/Spottedleaf/Tuinity/actions
ItemJoin dev 492

Ran into an issue with my TPS dropping with having some users join after a server restart. I began a timings profile and noticed ItemJoin was the cause of some lag. Is there any way to optimize the PlayerGuard PlayerMoveEvent further?

https://timings.aikar.co/?id=329b5615c09744299ab7d7a3a58b421d#plugins

Config.yml
https://paste.gg/p/anonymous/e21c1947b8554202921cc11f98f4de48/files/3586a3f8a28a437f9206932d2cfadd8d/raw

Items.yml
https://paste.gg/p/anonymous/95f5c00cbf654d049ee7e5217ff5272c/files/9b843bba706e4df39feedcb1377b24a9/raw

commented

So, after reviewing your timings report I would have to say that StreakRewards is the culprit for your lag on restart after players join. Confirmed by the PlayerJoinEvent pulling a LOT of ms delay. Likely because it is trying to ping a website to pull information or is waiting for an event that isn't executing. Or since it is a rewards plugin it could be using the main server thread to store streak information rather than running it async.

As for ItemJoin, I would say those timings are fairly normal, especially for an event that is literally triggered every time a player even sneezes. I am hoping in the future WorldGuard implements a better system with its own event handler rather than using such a crude system.

It is not nessisarly the percentage of a tick that a plugin uses rather how they use it. What causes lag and TPS drops is when a class hitches or gets stuck on a task on the main server thread and causes the whole server to wait for that task to complete. The way of determining the offending plugins is to target the ms delay per tick. ItemJoin is high up on the scale of tick usage but since its setup properly for pending tasks it has a low ms delay. Essentially, plugins can have high usage but not cause server lag as the ms delay is what causes the lag. (If that makes any sense, sorry it's pretty early, still need my coffee).

I have changed some things in regards to the PlayerGuard class to attempt to reduce timings but there wasn't much I could change other than moving things off the main server thread so hopefully, this will reduce the tick usage.
Snapshot; http://ci.craftationgaming.com/job/ItemJoin/493/
If you could provide a timings report after you download this snapshot that would be great.

Let me know!

commented

I have forwarded optimization requests to StreakRewards, thanks for the information! PlayerGuard looks to be a whole lot better after initial testing and quick timing profiling.

https://timings.aikar.co/?id=02d391d4cf1340a395e6ee8e105c38f6#plugins