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

Move PlayerProfile saving off the main thread #4119

Merged
merged 2 commits into from
Feb 7, 2024

Conversation

WalshyDev
Copy link
Member

@WalshyDev WalshyDev commented Feb 4, 2024

Description

Moves the PlayerProfile saving off the main thread

Proposed changes

Move PlayerProfile off main thread, add debugs and improve tab completion for debug

Moved the PlayerProfile saving off the main thread, we generally load this off-thread but now we also save off-thread. I thought we were already doing this but apparently not, especially with our current YAML stuff this should definitely be done

Also done a small change to ensure that we don't remove the PlayerProfile from memory if the player is still online. I don't think we ever had a reported issue from this but it's kinda weird behaviour

Finally, added some debug logs to the saving logic, this can be enabled with /sf debug slimefun_player_profile_data. Also added auto-complete to /sf debug because it's nice, this only works for Slimefun test cases rather than addons but that's fine. Mostly internal anyway


Please consider any cases where this will cause issues and bring them up!

I think this should be generally safe since we've been saving on-thread but loading off-thread anyway for ages but we should exercise caution. I think with the extra enforcement of the player definitely still being offline there's no issue here but give it a think before approving :)

Related Issues (if applicable)

Resolves #4118

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.

@github-actions github-actions bot added the 🧹 Chores Refactoring / Cleanup. label Feb 4, 2024
Copy link
Contributor

github-actions bot commented Feb 4, 2024

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

Copy link
Contributor

github-actions bot commented Feb 4, 2024

Slimefun preview build

A Slimefun preview build is available for testing!
Commit: 5f6706bf

https://preview-builds.walshy.dev/download/Slimefun/4119/5f6706bf

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!

@WalshyDev
Copy link
Member Author

I tested a basic profile with just researches and with research + backpacks (both Slimefun items and vanilla). Each one could save without issue

@WalshyDev WalshyDev marked this pull request as ready for review February 4, 2024 23:00
@WalshyDev WalshyDev requested a review from a team as a code owner February 4, 2024 23:00
…tion for debug

Moved the PlayerProfile saving off the main thread, we generally load this off-thread but now we also save off-thread. I thought we were already doing this but apparently not, especially with our current YAML stuff this should definitely be done

Also done a small change to ensure that we don't remove the PlayerProfile from memory if the player is still online. I don't think we ever had a reported issue from this but it's kinda weird behaviour

Finally, added some debug logs to the saving logic, this can be enabled with . Also added auto-complete to /sf debug because it's nice, this only works for Slimefun test cases rather than addons but that's fine. Mostly internal anyway
@WalshyDev WalshyDev force-pushed the chore/move-player-data-save-off-main-thread branch from b3d2e4b to 3d13adc Compare February 4, 2024 23:07
J3fftw1
J3fftw1 previously approved these changes Feb 5, 2024
Copy link
Member

@Sfiguz7 Sfiguz7 left a comment

Choose a reason for hiding this comment

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

Can't think of a case in which this would fail if the original worked so LGTM

Copy link

sonarcloud bot commented Feb 6, 2024

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

9 New issues
0 Security Hotspots
19.2% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

@WalshyDev WalshyDev added the 💡 Performance Optimization This pull request improves performance. label Feb 6, 2024
@WalshyDev WalshyDev merged commit da9c2ac into master Feb 7, 2024
16 checks passed
@WalshyDev WalshyDev deleted the chore/move-player-data-save-off-main-thread branch February 7, 2024 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧹 Chores Refactoring / Cleanup. 💡 Performance Optimization This pull request improves performance.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

move auto saves from main thread to off thread
3 participants