[SPIGOT-3595] net.minecraft.server.v1_12_R1.TileEntityHopper.o() 80.1% 240300ms Created: 05/Oct/17  Updated: 28/Oct/17  Resolved: 28/Oct/17

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: NullCase Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: 1.12.2, Entity, bug, hopper, tps
Environment:

I am new, but I will try to provide clear and useful information.

Windows and also on independant host (probably debian?) 10GB server online, 6GB while testing offline.

Bug is observable while running the latest version(s) of worldguard (I tried three versions, all since 1.12)

 


Plugin: WorldGuard

 Description   

I am new, but I will try to provide clear and useful information.

Since 1.12.2 I experienced major TPS lag. Narrowed the issue down to WorldGuard, but the developer believes it is a bug in Spigot.

Seems like there was an update to hoppers and this is causing some CPU drag.

1) CPU profile generated by WorldGuard [http://paste.enginehub.org/HNZpQO.profile
]

Note that Hoppers are using up roughly 80%. 

2) Contact with developer of world guard (lower comments)
 http://dev.enginehub.org/youtrack/oauth?state=%2Fyoutrack%2Fissue%2FWORLDGUARD-3870

3) Additional images for context* Note: TPS was 10 on server. Screenshot from offline/independant test.
https://www.spigotmc.org/attachments/2017-10-02_17-30-50-png.285364/

 

4) Temporary workaround by removing WorldGuard.



 Comments   
Comment by blablubbabc [ 25/Oct/17 ]

According to those profiling results, a majority of the time spent for creating those BlockState snapshot TileEntities is actually spent inside Class#getSimpleName(), inside the SpigotTimings.getTileEntityTimings().

It actually seems that Class#getSimpleName might be a lot slower, than, for example, Class#getName() (which seems to get cached internally by Class). Actually, minecraft itself had an issue with this in the past: https://bugs.mojang.com/browse/MC-117087

Maybe it might make sense to use something differently inside SpigotTimings, for identifying Entity and TileEntity types. Or cache the result of getSimpleName, as already suggested by md_5 here for a similar issue in the past: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/pull-requests/336/overview

Would be interesting to see how large of a difference this change would already make.

Comment by Black Hole [ 24/Oct/17 ]

I saw in the code that there are up to two BlockStates created for each call to InventoryMoveItemEvent. Those create a snapshot of the TileEntity in it's constructor.

Maybe we could just avoid calling "getOwner().getInventory()" and just use "new CraftInventory(this)" in TileEntityHopper? (And maybe some other places, too.)

Comment by NullCase [ 24/Oct/17 ]

Thanks for your help. The statement above quoted is the reason I contacted you. Apologies for providing unrelated info (thinking it was relevant).

Thanks again.

Comment by Black Hole [ 24/Oct/17 ]

2,302 hoppers ain't that much, but more than your server can handle in combination with WorldGuard.
You should get a faster CPU or limit the hoppers each player could use. There is also an option in spigot.yml to limit the time per tick for entities and tile entities like hopper. You'll find these options under "max-tick-time". Test with some values between 5 and about 25.

For the statement "it's definitely not correct for hoppers to be creating new tile entity instances every time their inventory holder is accessed" I'll have a look at the code.

Anyway, this issue tracker is for issues with the Spigot server software. Your issue is more your limited hardware and configuration issue. And for configuration issues please use the community support on the Spigot forums.

Comment by NullCase [ 24/Oct/17 ]

OK, found out how to reply here.[

https://timings.spigotmc.org/?url=wufoqijagi]

Here's a timings report. This is live on the server now a couple weeks later. Still no luck in solving this problem.

People use hoppers of course but there's nothing obviously gigantic.

The issue happened all at once with 1.12.1 and since then.

WorldGuards' developer noticed something and I'm not sure how Here'es the quotes from this link:
http://dev.enginehub.org/youtrack/issue/WORLDGUARD-3870

>" tell them that it's definitely not correct for hoppers to be creating new tile entity instances every time their inventory holder is accessed."

>"this is really an issue that needs to be solved in the server, but the new option should at least mitigate it a bit."

Comment by md_5 [ 05/Oct/17 ]

We've had the 1.12.2 hopper changes in Spigot for years, there was no recent change in that respect.
42% of your profile report is WorldGuard not Spigot.
I would suggest someone built a gigantic hopper contraption and that's just causing issues exacerbated by your plugins

Comment by Black Hole [ 05/Oct/17 ]

Spigot has a /timings command. It'll help determine the number of hoppers being ticked.

Currently there are no config options in Spigot that improves hopper performance or disable InventoryMoveEvent for hoppers.

But there's an option to limit the tick time for entities and tile entities in spigot.yml

Generated at Tue Sep 02 21:51:32 UTC 2025 using Jira 10.3.9#10030009-sha1:eff8913ed2270ee44ab422c3609af4c4f36536d0.