2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Antony Riley <antony@cyberiantiger.org>
|
|
|
|
Date: Tue, 29 Mar 2016 08:22:55 +0300
|
|
|
|
Subject: [PATCH] Sanitise RegionFileCache and make configurable.
|
|
|
|
|
|
|
|
RegionFileCache prior to this patch would close every single open region
|
|
|
|
file upon reaching a size of 256.
|
|
|
|
This patch modifies that behaviour so it closes the the least recently
|
|
|
|
used RegionFile.
|
|
|
|
The implementation uses a LinkedHashMap as an LRU cache (modified from HashMap).
|
|
|
|
The maximum size of the RegionFileCache is also made configurable.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
2021-11-09 08:59:15 +01:00
|
|
|
index 817d4572c9991992b720b3ba163188ac0e5b59b7..01da2246c70237676597b3e70e3e169ab1132071 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
2021-11-09 08:59:15 +01:00
|
|
|
@@ -239,4 +239,9 @@ public class PaperConfig {
|
2021-06-11 14:02:28 +02:00
|
|
|
private static void loadPermsBeforePlugins() {
|
|
|
|
loadPermsBeforePlugins = getBoolean("settings.load-permissions-yml-before-plugins", true);
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ public static int regionFileCacheSize = 256;
|
|
|
|
+ private static void regionFileCacheSize() {
|
|
|
|
+ regionFileCacheSize = Math.max(getInt("settings.region-file-cache-size", 256), 4);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
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
|
2021-10-05 05:14:11 +02:00
|
|
|
index a0516f72671522a6d7d9ea649506760f120b88bd..3d07235ad34d219c7c5fccd216a3a6935ced645c 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
2021-06-16 00:24:12 +02:00
|
|
|
@@ -35,7 +35,7 @@ public class RegionFileStorage implements AutoCloseable {
|
2021-06-11 14:02:28 +02:00
|
|
|
if (regionfile != null) {
|
|
|
|
return regionfile;
|
|
|
|
} else {
|
|
|
|
- if (this.regionCache.size() >= 256) {
|
|
|
|
+ if (this.regionCache.size() >= com.destroystokyo.paper.PaperConfig.regionFileCacheSize) { // Paper - configurable
|
|
|
|
((RegionFile) this.regionCache.removeLast()).close();
|
|
|
|
}
|
|
|
|
|