SpongePowered / SpongeForge

A Forge mod that implements SpongeAPI
http://www.spongepowered.org/
MIT License
1.14k stars 306 forks source link

Massive lag spike when using Entity.toContainer() on a modded player (MemoryDataView.set() memory hog) #3198

Open LemADEC opened 4 years ago

LemADEC commented 4 years ago

I am currently running

Plugins (21): Minecraft, Minecraft Coder Pack, SpongeAPI, Sponge, AntiWDL, BetterChunkLoader, Brotkasten, Buycraft, CatClearLag, GriefDefender, HuskyCrates, HuskyUI, LuckPerms, MagiBridge, NuVotifier, Nucleus, Prism, Server Backup, Total Economy, WrapperPing, spark

Issue Description Whenever a player dies a lag spike of a few seconds is observed. Here's a profiling result over 5 mn while I did /suicide myself 19 times: https://spark.lucko.me/#1P1e1k76UW image

From the look of it, the MemoryDataView.set() method is duplicating the whole data structure whenever setting new content. The initial call to Entity.toContainer() account for ~4.65%, then the plugin add UnsafeData, encapsulate into an entity, add some id and version tag for a total of ~19% of CPU load (approximately 3 s lag per death).