TPS Lagg with Sentinels, Citizens
LadyCailinBot opened this issue ยท 6 comments
WORLDGUARD-3962 - Reported by StormyIceLeopard
When I set up Sentinels with Citizens for my server everytime the sentinel attacked a target it caused TPS drop, from 20 to as low as 11. And I discovered that world guard was the issue because when I removed it from my plugins folder the issue was resolved. But I need world guard as well for other reasons. I hope this helps resolve this issue as smoothly and quickly as possible.
There used to be errors in log but I updated to latest dev build: WorldGuard version 6.2.2-SNAPSHOT;1727-8eeab68
And that removed the errors in console.
The TPS drops when the sentinel hits/kills the target mob, in example a creeper.
Comment by me4502
Please provide a profile using /wg profile -p
whilst the slow period is occurring.
Comment by StormyIceLeopard
Video I recorded while making that profile: https://youtu.be/PfTQcwidjR4
Profile result: http://paste.enginehub.org/mu3DY7.profile
Comment by PseudoKnight
The performance drop is a permission check on the fake player. Apparently this is intensive in PEX. Fortunately WG will skip this permission check if you surround the fake player's name in brackets. (eg. "[SentinelGuy]" instead of "SentinelGuy")
While this is a working short term solution, an "NPC" metadata check should probably be added to that InteropUtils.isFakePlayer() method as well. In another ticket this was discussed, and while some reports suggested that the metadata wasn't applied soon enough in all cases, I couldn't verify that. It worked for me in all cases. But the player NPCs fire almost every player event, which is annoying.
So, in general I recommend avoiding fake players because most plugins expect players to be players, and this can cause all sorts of problems. You can, however, use another type of entity disguised as a player using packets.
Comment by me4502
@PseudoKnight Can you please provide the metadata check code that you've used?
Comment by StormyIceLeopard
Changing the Name from: Spawn Protector
to: [SpawnProtector]
did fix the issue. But if this is a PEX issue, then why does disabling WorldGuard fix the TPS lagg as well?
Comment by PseudoKnight
This is the convention used and it at least works with Citizens: player.hasMetadata("NPC");
But if this is a PEX issue, then why does disabling WorldGuard fix the TPS lagg as well?
I wouldn't say it's a PEX or WorldGuard issue. It's a fake player issue. Any plugin that checks a permission for what appears to be a player will probably have this occur in PEX (other problems aside). You just happen to be using those player entities to shoot things, which causes a damage event. If you were to have them break blocks or use levers, this would also cause the same problem. I encountered it a lot with teleportation, which occurs when they spawn in too. I'm not sure why this operation on fake player entities is slow in PEX. Half the time is due to initialization, which looks like it should only happen once per UUID. Maybe it's a bug in your version. But that's still only half the operation time. Anyway, if you want to be sure to avoid these issues, don't use fake player entities on the server. Disguise them if needed. Or, you can try tackling the problems one by one as they keep coming up.