Fix the ForgeChunkManager to use the writebehind FileIO thread for writing (#4777)
the chunk file. Closes #4775 This is a performance tweak - doing File IO on the server thread during world saves causes significant lag spikes. This is one of many.
This commit is contained in:
parent
e299489493
commit
18144b7a0a
|
@ -44,6 +44,7 @@ import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.WorldServer;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
|
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
|
||||||
|
import net.minecraft.world.storage.ThreadedFileIOBase;
|
||||||
import net.minecraftforge.common.config.ConfigCategory;
|
import net.minecraftforge.common.config.ConfigCategory;
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
import net.minecraftforge.common.config.Property;
|
import net.minecraftforge.common.config.Property;
|
||||||
|
@ -944,6 +945,9 @@ public class ForgeChunkManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write the actual file on the IO thread rather than blocking the server thread
|
||||||
|
ThreadedFileIOBase.getThreadedIOInstance().queueIO(() -> {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CompressedStreamTools.write(forcedChunkData, chunkLoaderData);
|
CompressedStreamTools.write(forcedChunkData, chunkLoaderData);
|
||||||
|
@ -951,8 +955,9 @@ public class ForgeChunkManager
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
FMLLog.log.warn("Unable to write forced chunk data to {} - chunkloading won't work", chunkLoaderData.getAbsolutePath(), e);
|
FMLLog.log.warn("Unable to write forced chunk data to {} - chunkloading won't work", chunkLoaderData.getAbsolutePath(), e);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static void loadEntity(Entity entity)
|
static void loadEntity(Entity entity)
|
||||||
|
|
Loading…
Reference in New Issue