-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove all locks in Linear region files
- Loading branch information
1 parent
6b04640
commit b435860
Showing
12 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
132 changes: 132 additions & 0 deletions
132
patches/server/0054-LinearPurpur-Just-remove-all-locks-on-region-files.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Xymb <[email protected]> | ||
Date: Sat, 9 Dec 2023 23:06:25 +0100 | ||
Subject: [PATCH] LinearPurpur: Just remove all locks on region files | ||
|
||
Original license: MIT | ||
Original project: https://github.com/StupidCraft/LinearPurpur | ||
|
||
Original project: https://github.com/xymb-endcrystalme/LinearPaper | ||
|
||
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 e67543ef424d448096379bef118b8cb24b938964..be10a534a8e58e0f96c3b28dc74513e4cfff2464 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(); // LinearPurpur | ||
+ //regionFile.getFileLock().unlock(); // LinearPurpur | ||
} | ||
} | ||
} | ||
@@ -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(); // LinearPurpur | ||
+ //regionFile.getFileLock().lock(); // LinearPurpur | ||
} | ||
} | ||
|
||
@@ -1166,7 +1167,7 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread { | ||
return function.apply(regionFile); | ||
} finally { | ||
if (regionFile != null) { | ||
- regionFile.getFileLock().unlock(); // LinearPurpur | ||
+ //regionFile.getFileLock().unlock(); // LinearPurpur | ||
} | ||
} | ||
} | ||
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 8ee307a453e79e59444f5c5b8b45ffc7755237c7..6d696f6945c4e08d58616505b961e56fd5a04fcf 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 | ||
@@ -137,7 +137,7 @@ public class RegionFileStorage implements AutoCloseable { | ||
// Paper start | ||
if (lock) { | ||
// must be in this synchronized block | ||
- regionfile.getFileLock().lock(); // LinearPurpur | ||
+ //regionfile.getFileLock().lock(); // LinearPurpur | ||
} | ||
// Paper end | ||
return regionfile; | ||
@@ -149,6 +149,7 @@ public class RegionFileStorage implements AutoCloseable { | ||
// Paper end - cache regionfile does not exist state | ||
if (this.regionCache.size() >= io.papermc.paper.configuration.GlobalConfiguration.get().misc.regionFileCacheSize) { // Paper - Sanitise RegionFileCache and make configurable | ||
this.regionCache.removeLast().close(); // LinearPurpur | ||
+ //System.out.println("Region file cache overflowed, closing " + this.regionCache.size()); // LinearPurpur | ||
} | ||
|
||
// Paper - only create directory if not existing only - moved down | ||
@@ -186,7 +187,7 @@ public class RegionFileStorage implements AutoCloseable { | ||
// Paper start | ||
if (lock) { | ||
// must be in this synchronized block | ||
- regionfile1.getFileLock().lock(); // LinearPurpur | ||
+ //regionfile1.getFileLock().lock(); // LinearPurpur | ||
} | ||
// Paper end | ||
return regionfile1; | ||
@@ -266,7 +267,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()); // LinearPurpur | ||
if (regionfile.recalculateHeader()) { | ||
- regionfile.getFileLock().lock(); // otherwise we will unlock twice and only lock once. // LinearPurpur | ||
+ //regionfile.getFileLock().lock(); // otherwise we will unlock twice and only lock once. // LinearPurpur | ||
return this.read(pos, regionfile); | ||
} | ||
net.minecraft.server.MinecraftServer.LOGGER.error("Can't recalculate regionfile header, regenerating chunk " + pos + " for " + regionfile.getRegionFile().toAbsolutePath()); // LinearPurpur | ||
@@ -303,7 +304,7 @@ public class RegionFileStorage implements AutoCloseable { | ||
|
||
return nbttagcompound; | ||
} finally { // Paper start | ||
- regionfile.getFileLock().unlock(); // LinearPurpur | ||
+ //regionfile.getFileLock().unlock(); // LinearPurpur | ||
} // Paper end | ||
} | ||
|
||
@@ -395,7 +396,7 @@ public class RegionFileStorage implements AutoCloseable { | ||
// Paper end - Chunk save reattempt | ||
// Paper start - rewrite chunk system | ||
} finally { | ||
- regionfile.getFileLock().unlock(); // LinearPurpur | ||
+ //regionfile.getFileLock().unlock(); // LinearPurpur | ||
} | ||
// Paper end - rewrite chunk system | ||
} | ||
diff --git a/src/main/java/org/purpurmc/purpur/region/LinearRegionFile.java b/src/main/java/org/purpurmc/purpur/region/LinearRegionFile.java | ||
index 731a90436cae2e615c228c07f042fa112b95a8d2..3897e28975db9666ec91668a1481df926f300be5 100644 | ||
--- a/src/main/java/org/purpurmc/purpur/region/LinearRegionFile.java | ||
+++ b/src/main/java/org/purpurmc/purpur/region/LinearRegionFile.java | ||
@@ -61,6 +61,11 @@ public class LinearRegionFile implements AbstractRegionFile, AutoCloseable { | ||
|
||
if (!regionFile.canRead()) return; | ||
|
||
+ // LinearPurpur start - Remove all locks | ||
+ long start = System.currentTimeMillis(); | ||
+ //if (regionFile.toString().contains("region")) while (System.currentTimeMillis() < start + 2000); | ||
+ // LinearPurpur end | ||
+ | ||
try (FileInputStream fileStream = new FileInputStream(regionFile); | ||
DataInputStream rawDataStream = new DataInputStream(fileStream)) { | ||
|
||
@@ -113,6 +118,7 @@ public class LinearRegionFile implements AbstractRegionFile, AutoCloseable { | ||
this.bufferUncompressedSize[i] = size; | ||
} | ||
} | ||
+ //System.out.println("Opening region file " + this.regionFile + " took " + (System.currentTimeMillis() - start) + "ms"); // LinearPurpur - Remove all locks | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.