Slimefun / Slimefun4

Slimefun 4 - A unique Spigot/Paper plugin that looks and feels like a modpack. We've been giving you backpacks, jetpacks, reactors and much more since 2013.
GNU General Public License v3.0
958 stars 547 forks source link

Fixes exhaustion when loading large profiles #4127

Closed WalshyDev closed 6 months ago

WalshyDev commented 6 months ago

Description

Fixes exhaustion when loading large PlayerProfiles due to multiple load calls being made. If we're already loading the profile, we don't want to spin up a whole new thread and load the profile again/more. This can very easily cause CPU, memory and thread exhaustion if the profile is large

We saw AbstractArmorTask constantly try to get the PlayerProfile (every 10 mc ticks) even though the profile was still being loaded (due to it's very large size). This compounded the issue and ended up killing servers off entirely.

Proposed changes

Add tracking for when we're loading the PlayerProfile from file into memory. If the profile is loading, we will simply return and not try to load it again. This does mean that callbacks for PlayerProfile#get are currently tossed away, this isn't ideal but IMO is acceptable here. It will just mean if someone interacts with a block/item quickly and they have a large profile, instead of the interaction happening after load it will just not happen and they will need to re-interact. This is only for first load so not a big deal but worth calling out.

Related Issues (if applicable)

Fixes #4011 Fixes #4116

Checklist

github-actions[bot] commented 6 months ago

Your Pull Request was automatically labelled as: "✨ Fix" Thank you for contributing to this project! ❤️

sonarcloud[bot] commented 6 months ago

Quality Gate Passed Quality Gate passed

Issues
12 New issues

Measures
0 Security Hotspots
66.7% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

github-actions[bot] commented 6 months ago

Slimefun preview build

A Slimefun preview build is available for testing! Commit: 99c7411b

https://preview-builds.walshy.dev/download/Slimefun/4127/99c7411b

Note: This is not a supported build and is only here for the purposes of testing. Do not run this on a live server and do not report bugs anywhere but this PR!