Hats

Hats

24M Downloads

TickHandlerServer does some crazy expensive operations every tick

oxguy3 opened this issue ยท 10 comments

commented

hats taking a long time each tick

According to Opis, the TickHandlerServer class in Hats is taking ~100 nanoseconds per tick of CPU time, which is huge considering most other Handlers take ~5 nanoseconds or less.

Looking at that class' source code, I'd guess that the problem is that it is looping through the entire list of loaded entities on every single world tick. It looks like that loop basically looks for EntityLivingBases that don't have a corresponding string in the WeakHashMap mobHats, and sets one. It seems to me like it could just as easily listen for LivingSpawnEvents; every time an entity spawns, that's when it could set a string for it in hatMobs.

commented

There's a LivingSpawnEvent?? :O TIL.

Will look into this. Thanks!

commented

Looks to be fixed in 2.1.8, will report back if anything goes wrong! Thanks a lot!

commented

Hmm, perhaps EntityJoinWorldEvent would work then?

commented

I'll look into that later. Thanks.
On 11 Apr 2014 05:20, "Hayden Schiff" [email protected] wrote:

Hmm, perhaps EntityJoinWorldEvent would work then?

Reply to this email directly or view it on GitHubhttps://github.com//issues/90#issuecomment-40144355
.

commented

Awesome, thanks! Any chance this change would be backported for 1.6.4?

commented

I've took a quick look at it a while ago, and unfortunately that spawn
event is only used for natural spawns, and not for mobs already in the
world from another method.

This was just a quick glance of course though, so there might be a better
method that I'll find later on.

Yes it'll be back ported to 1.6 since its an major optimisation change.
On 11 Apr 2014 05:09, "Hayden Schiff" [email protected] wrote:

Awesome, thanks! Any chance this change would be backported for 1.6.4?

Reply to this email directly or view it on GitHubhttps://github.com//issues/90#issuecomment-40143302
.

commented

Sorry that this took a while, but Hats has updated to 2.1.6, with an experimental fix for the load issue. Please try it out and let me know if the situation improves.

commented

Opis

Still getting high update time for hats with Hats 2.1.6.

commented

Can you try 2.1.7? I'm trying to fix it again at another spot. It's really hard to track down. http://ichun.us/hats-updated-to-2-1-7/

commented

Actually.. Can you try 2.1.8 now as well? This one might have really tackled the issue.
http://ichun.us/hats-updated-to-2-1-8/