Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Async Autosaving #17

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

TheStratagemMC
Copy link

A problem my server ran into is that autosaving the chests every 10 minutes paused the server for about 15 seconds each time, so I decided to try to make the saving async. I'm not sure I did this correctly without causing memory leaks and other stuff that scared me in the first place, but the lag seems to be gone.

I also added a value in the config for toggling async, but i'm pretty sure that it would be always set to false for people that don't have the new configuration file.

I'm making the pull request on the chance that you might be interested in this. If you are, you probably have to fix the configuration to use true by default. i didn't want to change the code too drastically, i just added in a class for async saving.

@TheStratagemMC
Copy link
Author

Oh so, I know nothing about threads. I implemented runnable instead of doing extends thread, trying a separate thread now.

@TheStratagemMC
Copy link
Author

i believe this is working now

@Brianetta
Copy link
Collaborator

I shall have a look at this, with a view to merging it. Might take me a couple of days because it's the work week now.

@ShadowRanger
Copy link
Collaborator

I haven't gotten around to continuing the work on the next update that I had started. I apologise for that. I'll do some work today and update on my progress. I shall also look into this pull request as I understand that you might be busy this week Brianetta.

@TheStratagemMC
Copy link
Author

actually, i don't think the async stops the lag, because it's returning the number of chests saved each time, and the server thread still blocks until it gets the number of chests? i'll try to fix this real quick, but my solution probably won't include reporting the number of chests saved.

still, I'm pretty sure this is worth it to keep the server from pausing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants