Game lags when abilities reach over +800%
markusvisse opened this issue ยท 31 comments
Describe the bug
Seems that when you reach ability exp gain over 800% an show the ability overlay in-game the game starts to lag. If you turn it off the game works fine. So it looks like there must be some massive calculations going on in the background when showing the overlay? In UV modpack it's by default under Left Alt.
Expected behavior
No lag when viewing the stats.
To Reproduce
Steps to reproduce the behavior:
- Put on items giving some ability boost in total over 800%
- Experience lag
Versions:
- Minecraft: 1.19.2
- Loader: Forge-43.1.47
- PMMO: 1.19.2-0.5.3
- Modpack: UVision 1.18
I tested this with just forge and pmmo and was unable to reproduce the issue. It is possible this issue only occurs at scale, however the myriad of variables that a modpack can introduce means this requires more reports of this behavior at scale.
I've checked this in the same setup as yours and having a full leather armor giving +420% give me now small frame drop. It's not as bad as anything above 800% but still noticeable.
Is there anything else I can use to boost the bonus to double check it?
I have tested it with this as well and you can see here: https://files.fm/u/b9wamwxyf#/view/dswradu6d after toogling the stats it starts to drop.
@Caltinor Managed to reproduce this:
- Install Minecraft 1.19.2
- Install Forge-43.1.47
- Install PMMO 1.19.2-0.5.3
- Create singleplayer game with cheats enabled
- Install
vanilla
datapack from https://github.com/Caltinor/PMMO-Official-Datapack/tree/main/datapacks/vanilla - Give yourself 4 pieces of leather armor
- Put them on
- Lag city
hmm. you shouldn't need the official datapack for any version anymore. that said, if you are getting lag spikes, then it's definitely a bug that isn't just related to hardware. I'll take a look at this.
The lag only happens when you have the skill readout up. With that gone, the game runs fine. At a guess, something in the way the display calculates NBT bonuses is the culprit.
It's also worth mention that the greater the bonus the greater the lag. In the video there was barely 800-900%, while having few thousands makes it really hard to do anything. Maybe try adding an item with 10k bonus, this should give at least a small lag for you hopefully.
If it helps, I use MultiMC and here is a download for the instance I used: https://excessive.space/download/1.19.2%20Lag.zip
Same, no lag from those two items. But leather armor using the (old)
tag_leather_armor.json
that usesnbt_bonuses
still does.
If you're using the official datapack then you're creating duplicate code for the NBT bonus and it's running twice. the NBT bonuses for leather are built into the mod so the official datapack is just duplication.
Test No.2: no config aggregation. In this test i have removed the code which grabs all the configurations and provides the bonus value. You will see them render, but you won't be able to set them. This one might be harder to test. I suggest using /pmmo admin @p clear
to remove all skills. agility has an 800% bonus and engineering has a 4900% bonus. if this does not solve the issue you should be able to see no lag when there is no xp in anything, some lag once you gain some agility, and massive lag if you give yourself some engineering xp.
pmmo-1.19-0.5.4-noAggregate.zip
I think you both found the issue, but I want to be certain there isn't more.
I can confirm this without the datapack. Created a new world and with your nether star and cookie all works fine. With equipped leather armor + golden axe = lag.
I can confirm this without the datapack. Created a new world and with your nether star and cookie all works fine. With equipped leather armor + golden axe = lag.
๐ค I may need to optimize the NBT code a bit. ๐ก AHA! I actually came up with a simple solution just now.
Looks fine now. Even with the leather armor. No lag with both agility and engineering. Hope the solution is actually as simple as you have it in mind ๐
Test No.2: no config aggregation. In this test i have removed the code which grabs all the configurations and provides the bonus value. You will see them render, but you won't be able to set them. This one might be harder to test. I suggest using
/pmmo admin @p clear
to remove all skills. agility has an 800% bonus and engineering has a 4900% bonus. if this does not solve the issue you should be able to see no lag when there is no xp in anything, some lag once you gain some agility, and massive lag if you give yourself some engineering xp. pmmo-1.19-0.5.4-noAggregate.zipI think you both found the issue, but I want to be certain there isn't more.
This fixes it (for the modified nbt_bonuses
leather, yes. Though interestingly I just noticed there is still lag when you mouseover the leather armor for stats.
The mouseover is a different gui. the reason it doesn't lag on the skill list is because technically the NBT setting isn't being read. But the tooltip is a different gui, that i didn't modify, so it does read the NBT. So looks like we have two sources of lag. one is the NBT configurations. Independently though, the rendering of the values themselves is causing lag. So i've narrowed that down. I am going to work a bit on both of these and I will get back to each of you with a potential solution. I will also be creating a different issue specifically for the NBT bit so they don't get conflated.
May it be hardware dependant after all? Or some setting in MC? But to be honest I did not change anything after installing this.
I don't think it's hardware dependent. The laptop I use to code on the train is a literal toaster and that had no issues. Here is my proposed solution. I will make test jars which remove what I think is the issue. If you get no lag from that jar, then I know that is where the lag is coming from and we can narrow down from there. Would you all be willing to help in that way?
Test No.1: no rendering. In this test i have removed the code which renders the bonuses. The bonuses are still there on the server side, but won't be visible to the player. This is to check if the rendering code is the cause. for your test, cookies have an 800% modifier, and a nether star has a 4900% modifier. both are held bonuses.
pmmo-1.19-0.5.4-noRender.zip
Same, no lag from those two items. But leather armor using the (old) tag_leather_armor.json
that uses nbt_bonuses
still does.
Okay, this is a first attempt at a fix for this issue. In simple terms, this caches most of the calculations related to rendering the list so that they are only performed every 10 ticks instead of every tick.
pmmo-1.19-0.5.4-cachedRender.zip
woo!! i'll wait for confirmation from @markusvisse as well then i'll commit this and close the issue.
Looking at the leather armor I still have the lag. I am sure I'm using the cachedRender version.
Leather armor is going to still be an issue because i need to optimize the NBT bonuses. can you confirm that regular items that don't use NBT configurations no longer cause lag?
Wait, should I test it with a custom item or do the prevous boost still exist? If they exist then I have no lag with them.