vadis365 / PrimalTech

Stuff for SevTech3
8 stars 6 forks source link

Bad Network Performance #38

Open SeraphJACK opened 4 years ago

SeraphJACK commented 4 years ago

Synopsis

I'm playing FTBI with my friends using a tiny bandwidth server. And we encountered a network issue: in some players' home, network usage can be at 300 KiB/s, which is unreasonable.

After investigation, we found that nearly 80% of these are caused by primal_tech, because it keeps sync nbt data all the time.

Suggestion

You can do lazy updates, just like the vanilla furnace. Besides, not all data is necessarily needed to synchronize, don't always use writeToNBT.


@Yesterday17 @3TUSK

Yesterday17 commented 4 years ago

Useless entries

Let's see this example: WoodenHopper. https://github.com/vadis365/PrimalTech/blob/18f8fbc5800b7d6db30cc226d2d644a9b8d8669d/src/main/java/primal_tech/tiles/TileEntityWoodenHopper.java#L79-L83 It uses writeToNBT, which makes all its nbt transferred each update. And in fact, the client doesn't need to know the following values: https://github.com/vadis365/PrimalTech/blob/18f8fbc5800b7d6db30cc226d2d644a9b8d8669d/src/main/java/primal_tech/tiles/TileEntityWoodenHopper.java#L67-L68 They should be kept in NBT(or maybe not, since rotation can be stored as BlockState), but it's only useful for servers, and should NOT sent to client.

Inventory

The TileEntityInventoryHelper which is extended by all TileEntities with inventory, is a problem. And maybe it's the most severe one. It transfers all its ItemStacks to client every update, which uses too much bandwidth. In fact, it should only be sent when its content changes (and it's the simplest solution).

Suggestion: Flag(Configuration)

Since all the data transferred is used for render and many players have mods such as TOP installed, could you please introduce a flag to make it able to be disabled? For server who wants to save bandwidth, it can switch it off, making all the nbt not transferred to clients.