Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
PlayerUpdateTask high CPU usage #1339
Hi. Over the last few weeks, I've noticed consistently high timings for the PlayerUpdateTask.
We have a lot of pathfinding NPCs on our server, so I initially dismissed it as perhaps being reasonable. However, on closer inspection, it seems the part of the task which is consuming tick time isn't pathfinding.
With approx 100 players online, that task is occupying around 13% of the tick.
However, profiling shows that the biggest CPU drain in the entity tick is clearing advancement progress.
I'm going to trial moving this
on the assumption that it doesn't really need to be executed every time the NPC is ticked? Perhaps that's a bad assumption..? I don't know.
I felt I should at least make you aware of this, in case there's a more obvious fix you know of. :)
added a commit
Oct 29, 2017
Here're full timings: https://timings.aikar.co/?id=2033ae61c6e041909b8bf66a4e5405b5
I'd trust YourKit's sampling over the timings plugin sampling, although I'm not sure you have the right settings there as it's all being rounded down to 0. I use jProfiler myself and it has an option to report average time spent in function which would be more helpful if there is the same thing in YourKit.
Here's a different view:
Time(ms) is "Time spent in the method including time spent in subcalls.
Given the nature of how we use our NPCs, is there a "dumb mode" or set of commands we can utilize to reduce the number of checks done on NPCs? Our NPCs never move, never take damage, are only ever used for basic right-clicking and we have lookclose on for most of them. It seems a lot of work is being done to make these NPCs be a "normal player" in terms of the types of ticking checks going on.
Eh, again this isn't really helpful because it's not an average, just a total. Even this view shows that 100/33,564 = 0.3% of time total was spent in EntityHumanNPC#B_() which seems really miniscule compared to the rest of the subcalls. Why do you think Citizens is the problem here?