Files
LuminolMC/patches/server/0053-LinearPaper-Remove-all-locks-on-region-files.patch
2024-04-06 05:19:02 +00:00

97 lines
5.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrHua269 <novau233@163.com>
Date: Wed, 7 Feb 2024 06:30:38 +0000
Subject: [PATCH] LinearPaper Remove all locks on region files
diff --git a/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java b/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java
index b46acbc078f3d3bfb0f3ede3f1cc172f4b48c5df..812d8504c6abd16b34ee4abd976563f345f00d18 100644
--- a/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java
+++ b/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java
@@ -835,7 +835,8 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
return Boolean.TRUE;
}
- return file.hasChunk(chunkPos) ? Boolean.TRUE : Boolean.FALSE;
+ //return file.hasChunk(chunkPos) ? Boolean.TRUE : Boolean.FALSE;
+ return Boolean.TRUE;
});
}
}
@@ -1146,7 +1147,7 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
return function.apply(regionFile);
} finally {
if (regionFile != null) {
- regionFile.getFileLock().unlock(); // Kaiiju
+// regionFile.getFileLock().unlock(); // Kaiiju
}
}
}
@@ -1158,7 +1159,7 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
synchronized (cache) {
regionFile = cache.getRegionFileIfLoaded(new ChunkPos(chunkX, chunkZ));
if (regionFile != null) {
- regionFile.getFileLock().lock(); // Kaiiju
+// regionFile.getFileLock().lock(); // Kaiiju
}
}
@@ -1166,7 +1167,7 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
return function.apply(regionFile);
} finally {
if (regionFile != null) {
- regionFile.getFileLock().unlock(); // Kaiiju
+// regionFile.getFileLock().unlock(); // Kaiiju
}
}
}
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
index db9e4386ca95bdaba0a4a4e13e3a90d2bcfbae91..73fc6d393cb338fee7d866b99a4e25684d47e79b 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
@@ -120,7 +120,7 @@ public class RegionFileStorage implements AutoCloseable {
// Paper start
if (lock) {
// must be in this synchronized block
- regionfile.getFileLock().lock(); // Kaiiju
+// regionfile.getFileLock().lock(); // Kaiiju
}
// Paper end
return regionfile;
@@ -169,7 +169,7 @@ public class RegionFileStorage implements AutoCloseable {
// Paper start
if (lock) {
// must be in this synchronized block
- regionfile1.getFileLock().lock(); // Kaiiju
+// regionfile1.getFileLock().lock(); // Kaiiju
}
// Paper end
return regionfile1;
@@ -249,7 +249,7 @@ public class RegionFileStorage implements AutoCloseable {
if (!chunkPos.equals(pos)) {
net.minecraft.server.MinecraftServer.LOGGER.error("Attempting to read chunk data at " + pos + " but got chunk data for " + chunkPos + " instead! Attempting regionfile recalculation for regionfile " + regionfile.getRegionFile().toAbsolutePath()); // Kaiiju
if (regionfile.recalculateHeader()) {
- regionfile.getFileLock().lock(); // otherwise we will unlock twice and only lock once. // Kaiiju
+// regionfile.getFileLock().lock(); // otherwise we will unlock twice and only lock once. // Kaiiju
return this.read(pos, regionfile);
}
net.minecraft.server.MinecraftServer.LOGGER.error("Can't recalculate regionfile header, regenerating chunk " + pos + " for " + regionfile.getRegionFile().toAbsolutePath()); // Kaiiju
@@ -286,7 +286,7 @@ public class RegionFileStorage implements AutoCloseable {
return nbttagcompound;
} finally { // Paper start
- regionfile.getFileLock().unlock(); // Kaiiju
+// regionfile.getFileLock().unlock(); // Kaiiju
} // Paper end
}
@@ -378,7 +378,7 @@ public class RegionFileStorage implements AutoCloseable {
// Paper end - Chunk save reattempt
// Paper start - rewrite chunk system
} finally {
- regionfile.getFileLock().unlock(); // Kaiiju
+ //regionfile.getFileLock().unlock(); // Kaiiju
}
// Paper end - rewrite chunk system
}