BeetoGuy / LevelUp2

Rewrite of the original, with a skill tree
18 stars 14 forks source link

Performance issues for levelup2.event.CraftingSkillHandler.lambda$doFurnaceTicks ? #69

Closed Yarillo4 closed 4 years ago

Yarillo4 commented 4 years ago

I've ran a profiler because my server lags with ~8 players on it when it was at ~1 tick per second (1/20th the normal speed)

Now our lag issues are caused by several factors but it does seem like there are some performance weirdness in the DoFurnaceTicks function somehow ?

Here's a screenshot of the profiler

visualvm

(nps file for VisualVM here)

The profiler ran for 33 seconds and it spent 1.3s doing 120 invocations of lambda$doFurnaceTicks$0 in the event CraftingSkillHandler

The doFurnaceTicks function doesn't take much time itself it just seems to be doing the same work over and over again, could it possibly memoize the hasCapability() results or do these results change too often ?

I'm not sure if there's any issue in here - perhaps this thing actually has a lot of computing to do and there's not much that can be done. But I figured you might want to know, perhaps there's an unexpected optimization problem

BeetoGuy commented 4 years ago

The way it's handled is that it looks through the tile entity list every tick. That's probably where the most work is being done. I could cache compatible tile entities and release them on chunk load/unload respectively. I'll get back to you on that.

BeetoGuy commented 4 years ago

I have a build that you can test uploaded to Curse. You can find it here: https://www.curseforge.com/minecraft/mc-mods/level-up/files/2892251

KirikaAetheria commented 4 years ago

hello, I've upgraded to 1.2.6 yesterday, and I'm not sure whether or not the changes from 1.2.5 are present there, but if so, this issue is probably the proper one to comment on. shorter version at the bottom

I was using RFTools Dimensions, and noticed the activity probe (a block which disables power consumption on a dimension when no chunks are loaded inside it) wasn't doing its job properly. Spent a couple of hours today using chickenchunks /chunkloaders command trying to find out what was causing these chunks to not unload, and found out that furnaces were present on most of them. connecting the dots I realised that the remaining chunks probably had brewing stands, and that was indeed the case. -every- single one of those chunks had a furnace or brewing stand in it, and upon their removal, those chunks unloaded as normal

short version: the latest version seems to cause furnaces and brewing stands to remain loaded at all times

let me know if you need me to try something out on my end for more info

BeetoGuy commented 4 years ago

So that solution more or less turned furnaces into chunk loaders, good to know.

BeetoGuy commented 4 years ago

What I'm going to do is something I've been debating for the past few weeks, and that's using MixinBootstrap as a dependency so all the logic is done by the furnaces and brewing stands themselves. That should solve 99% of the problems these have been having.

KirikaAetheria commented 4 years ago

yeah, furnaces and brewing stands alike. hopefully that dependency will solve the issue then, it's sounding like a real nightmare to patch up