Description:
Since 1.18.2 (not 1.18.1 or earlier) and up to the current version (1.20.1), saving a small world takes several minutes on a dedicated server.
Specifically, on 1.18.1 I can create a new world and immediately stop the server. The save only takes about 8 seconds. Starting and stopping the server again takes only 2 seconds to save.
1.18.1 Save after world creation
[19:08:54] [Server thread/INFO]: Stopping the server
[19:08:54] [Server thread/INFO]: Stopping server
[19:08:54] [Server thread/INFO]: Saving players
[19:08:54] [Server thread/INFO]: Saving worlds
[19:08:54] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:overworld
[19:09:02] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:the_nether
[19:09:02] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:the_end
[19:09:02] [Server thread/INFO]: ThreadedAnvilChunkStorage (world): All chunks are saved
[19:09:02] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM-1): All chunks are saved
[19:09:02] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM1): All chunks are saved
[19:09:02] [Server thread/INFO]: ThreadedAnvilChunkStorage: All dimensions are saved
However, with the first 1.18.2 snapshot, 22w03a, creating and saving a new world takes ~2 minutes and 10 seconds, and starting and stopping takes about 1 minute and 30 seconds. This is an incredibly a long time for what is a very tiny world (12 MB).
1.18.2 Save after world creation
[19:13:01] [Server thread/INFO]: Stopping the server
[19:13:01] [Server thread/INFO]: Stopping server
[19:13:01] [Server thread/INFO]: Saving players
[19:13:01] [Server thread/INFO]: Saving worlds
[19:13:02] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:overworld
[19:15:11] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:the_nether
[19:15:11] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:the_end
[19:15:11] [Server thread/INFO]: ThreadedAnvilChunkStorage (world): All chunks are saved
[19:15:11] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM-1): All chunks are saved
[19:15:11] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM1): All chunks are saved
[19:15:11] [Server thread/INFO]: ThreadedAnvilChunkStorage: All dimensions are saved
1.20.1 Save after world creation
[19:20:10] [Server thread/INFO]: Stopping the server
[19:20:10] [Server thread/INFO]: Stopping server
[19:20:10] [Server thread/INFO]: Saving players
[19:20:10] [Server thread/INFO]: Saving worlds
[19:20:11] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:overworld
[19:22:15] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:the_end
[19:22:15] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:the_nether
[19:22:15] [Server thread/INFO]: ThreadedAnvilChunkStorage (world): All chunks are saved
[19:22:15] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM1): All chunks are saved
[19:22:15] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM-1): All chunks are saved
[19:22:15] [Server thread/INFO]: ThreadedAnvilChunkStorage: All dimensions are saved
For larger worlds with newly explored chunks, I've seen saving take up to 5 minutes!
Interestingly, Paper servers do not have this problem at all, their performance before and after 1.18.1 is fine. I imagine because they patch the chunk saving code.
Environment:
My server has 32GiB of RAM, 16 of which are free. 12 CPUs at about 20% usage. All this seems to suggest that the server has plenty of resources.
What now?
Certainly seems like a regression in 1.18.2+. If there is anything else I can do to help reproduce this, let me know.
Linked issues
is duplicated by 1
Comments 4
11:32:31.273 anz Server thread Stopping singleplayer server as player logged out
11:32:31.466 net.minecraft.server.MinecraftServer Server thread Stopping server
11:32:31.467 net.minecraft.server.MinecraftServer Server thread Saving players
11:32:31.467 net.minecraft.server.MinecraftServer Server thread Saving worlds
11:32:31.504 net.minecraft.server.MinecraftServer Server thread Saving chunks for level 'ServerLevel[Test Continents 1204]'/minecraft:overworld
11:50:51.472 net.minecraft.server.MinecraftServer Server thread Saving chunks for level 'ServerLevel[Test Continents 1204]'/minecraft:the_nether
11:50:51.473 net.minecraft.server.MinecraftServer Server thread Saving chunks for level 'ServerLevel[Test Continents 1204]'/minecraft:the_end
11:50:51.567 net.minecraft.server.MinecraftServer Server thread ThreadedAnvilChunkStorage (Test Continents 1204): All chunks are saved
11:50:51.567 net.minecraft.server.MinecraftServer Server thread ThreadedAnvilChunkStorage (DIM-1): All chunks are saved
11:50:51.567 net.minecraft.server.MinecraftServer Server thread ThreadedAnvilChunkStorage (DIM1): All chunks are saved
11:50:51.567 net.minecraft.server.MinecraftServer Server thread ThreadedAnvilChunkStorage: All dimensions are saved
After generating a lot of chunks using redstone, I exited to the main menu. It took over 18 minutes to save the Overworld with the disk near 100% most of the time.
Previous commenter says this was apparently patched by PaperMC but I have paper 1.21.1 build #128 and it is not fixed in t his version at least, but I only noticed it starting a few months ago. I just had to wait 10 minutes for my world to save and it happened a few times last month too. If you interrupt the process by force killing the process, you lose data.
openjdk 21.0.5 2024-10-15
OpenJDK Runtime Environment (build 21.0.5+11-Ubuntu-1ubuntu122.04)
OpenJDK 64-Bit Server VM (build 21.0.5+11-Ubuntu-1ubuntu122.04, mixed mode, sharing)
Turns out PaperMC patched this themselves here: https://github.com/PaperMC/Paper/blob/1.18.2/patches/server/0870-Fix-save-problems-on-shutdown.patch
I've confirmed that this does fix it by testing with and without the patch.
This patch (or something similar) should be applied upstream.