I recently started new playthrough with multiple mods and ran into performance issues, singleplayer was perfectly smooth, but multiplayer was performing worse on every client, especially noticable on AMD cpus which have worse per-thread performance.
So I poked around with profiler and noticed that in multiplayer on clientClone() method invoked from Terraria doUpdate() on main thread (it's only called on multiplayer client) where mod loader hooks with its ModPlayer.createFor method, where to my surprise I saw only one call with noticable performance: WingSlotPlayer.Initialize() which takes ~16% of thread time. That's a lot considering that main thread has to do all tick updates and rendering. Screenshot from profiler overview
Note though, that I never done any terraria mod development, so I don't know if it's intended to run on every tick. But since method is called "Initialize" I'd say it's not.
EDIT: After some more digging I found out that this is not such big issue when there are only few mods that don't add so many items, because Item.SetDefaults() takes more time the more recipes you have registered, up to some absurd values(it's prob vanilla flaw). Setting noMatCheck argument to true seems to be a workaround.
I recently started new playthrough with multiple mods and ran into performance issues, singleplayer was perfectly smooth, but multiplayer was performing worse on every client, especially noticable on AMD cpus which have worse per-thread performance.
So I poked around with profiler and noticed that in multiplayer on
clientClone()
method invoked from TerrariadoUpdate()
on main thread (it's only called on multiplayer client) where mod loader hooks with itsModPlayer.createFor
method, where to my surprise I saw only one call with noticable performance:WingSlotPlayer.Initialize()
which takes ~16% of thread time. That's a lot considering that main thread has to do all tick updates and rendering. Screenshot from profiler overviewNote though, that I never done any terraria mod development, so I don't know if it's intended to run on every tick. But since method is called "Initialize" I'd say it's not.
EDIT: After some more digging I found out that this is not such big issue when there are only few mods that don't add so many items, because
Item.SetDefaults()
takes more time the more recipes you have registered, up to some absurd values(it's prob vanilla flaw). Setting noMatCheck argument to true seems to be a workaround.