Just Enough Dimensions

Just Enough Dimensions

4M Downloads

Lag in JED world saving event handler

LemADEC opened this issue ยท 5 comments

commented

As of 1.12.2-1.6.0-dev.20190505.222902, lag is observed in JED while saving the world as seen in 5 mn profiling while just seating IDLE in the overworld:
image

commented

Can you try if this build fixes the issue? I moved the JED WorldInfo and DataTracker saving to the I/O thread, and disabled the Forge/FML data saving (handleWorldDataSave() in that profile) for the jed_level.dat files, as I don't think it's useful for anything in the custom dimensions anyway... maybe.

https://masa.dy.fi/tmp/minecraft/mods/jed/1.6.0-dev/justenoughdimensions-1.12.2-1.6.0-dev.20190525.125029.jar

commented

The only risks I can think of would be something like a dimension unloading and reloading very quickly, while the I/O thread is busy and takes a while to write the data to disk. Then again, since the data is written at every auto-save as well, the file should be there after the first save, and the save happens to a temporary file first, and then renaming it over the old file. So basically I think it would be extremely hard to produce a case where that change would cause any visible issues.

I can upload it to CurseForge later this evening if I remember. I just wanted to get at least some feedback first on whether or not the change fixed the issue you were seeing, as I don't have any good "real-world" test cases/instances, and I think the relatively slow saving is caused by the Forge registries or perhaps the dimension ID map being saved in a "proper" mod pack with lots of stuff. I also removed the Forge registry saving part as that's not used for anything in the custom dimensions anyway... except those jed level files previously kinda acting like partial backups of the main level.dat in case it got corrupted.

commented

Sorry for the late update.
With that build I don't see JED anywhere in the profiler (5 mn IDLE).
Any other risk with the threading change you want me to check?
When do you think we can get it pushed on CurseForge?

commented

I was more worried about a multi-threading issue like when the world is saving while a player start joining or generating in a JED dimension. For the record, the last profiling was with a small modpack (less than 3GB RAM required) with default JED configuration.

commented

The I/O-thread is (and is supposed to be) used for saving things to disk... but quite often at least I just tend to forget to use that. So as long as that thread doesn't try to access (at least without synchronization) any data from the main thread, then there shouldn't be any issues.