Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes exhaustion when loading large profiles #4127

Merged
merged 1 commit into from
Feb 14, 2024

Conversation

WalshyDev
Copy link
Member

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

  • I have fully tested the proposed changes and promise that they will not break everything into chaos.
  • I have also tested the proposed changes in combination with various popular addons and can confirm my changes do not break them.
  • I have made sure that the proposed changes do not break compatibility across the supported Minecraft versions (1.16.* - 1.20.*).
  • I followed the existing code standards and didn't mess up the formatting.
  • I did my best to add documentation to any public classes or methods I added.
  • I have added Nonnull and Nullable annotations to my methods to indicate their behaviour for null values
  • I added sufficient Unit Tests to cover my code.

@WalshyDev WalshyDev requested a review from a team as a code owner February 14, 2024 14:36
@github-actions github-actions bot added the ✨ Fix This Pull Request fixes an issue. label Feb 14, 2024
Copy link
Contributor

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

Copy link
Contributor

@J3fftw1 J3fftw1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since its just the initial request and only on the first few ticks of the player being joined i would say its fine
LGTM

Copy link

Copy link
Contributor

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!

Copy link
Contributor

@JustAHuman-xD JustAHuman-xD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM same as jeff

@Sfiguz7 Sfiguz7 merged commit 5be4718 into master Feb 14, 2024
19 checks passed
@Sfiguz7 Sfiguz7 deleted the fix/fix-exhaustion-when-loading-profiles branch February 14, 2024 14:56
WalshyDev added a commit to J3fftw1/Slimefun4 that referenced this pull request Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Fix This Pull Request fixes an issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

possibly out of memory or process/resource limits reached RAM overload with backpacks
4 participants