Optimize world save logic - #196
Conversation
|
Are you sure REGIONS_BY_FILE is already sorted by latest edition? Is that right? |
REGIONS_BY_FILE map is an access-ordered LinkedHashMap: |
|
1- I agree, i think the problem about "REGIONS_BY_FILE.keySet().iterator().next()" is a good idea. O(1) is good. And i can't see many other places this map can be acessed. 2- The fact that now CrucibleConfigs.configs.crucible_chunkCacheSize is used for both the and the might not be a good idea. 3- the variable p_71267_1_ All things could have solved your problem, i don't know each have. Maybe just because you have spoped flusing your saves at auto-saving solved it? Maybe the O(1) ? Maybe the fact you reduced the cache to 256 files and now all loops are at maximum that? |
Initiating the map with crucible_chunkCacheSize could skip the resize step, as the ori code did.
saveAllWorlds(boolean p_71267_1_ ) is called in only two places:
256 is the default size of chunkCacheSize, i did no change to that except removing the hardcode. But tha't true, I'm not sure which one did solve the lag spikes (or maybe both?). I will run more tests later today. |
|
OK I'm back. Test world size: 16.67GB; Set autosave in bukkit.yml to 400tick. Recorded tick time on world-save-tick: |
|
Thanks for digging into this, the RegionFileCache half is all correct. The cache size never being read was an incomplete Paper patch implementation. Your version is correct, the map is built with accessOrder=true so the first key really is the LRU one. Now the flush part. This was going to be an entire analysis of "this is a bandaid over a symptom", which it still is, but the flush call was introduced by bukkit and/or thermos in specific which is not a thing on vanilla and forge and clearly causes issues, the flag you are gating it behind is silent save however so just nuke the flush call entirely instead of gating behind it, otherwise everything is correct and ready to merge after you remove it instead of leaving behind the silent flag. This is the correct fix until incremental save is backported which that alone would be its own can of worms. |
|
Done! |
My GTNH Crucible server has suffered from periodic lag spikes for a long time. Spark shows this may mainly casued by the autosave's
flush()call. In default it will run a globalwaitForFinish()and closes every cached region file every 900tick. This will result in significant pause on server-thread when the world is larger then 5GB. Skipping the flush on autosave is safe since the autosave still writes chunks to disk every 900 tick.I also notice that the region-file cache size was hardcoded at 256 instead of reading
crucible_chunkCacheSize. Region-file eviction is now O(1) and use config's cache size.