geforkt von Mirrors/Paper
b6925c36af
This is now default vanilla behavior Fixes #3644
40 Zeilen
2.0 KiB
Diff
40 Zeilen
2.0 KiB
Diff
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
|
|
index f207abbe757ad403a29a7a012903aaa88d5b1685..7d726757d1083011a09c9f2ca37c33a81360e964 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
@@ -219,4 +219,9 @@ public class PaperConfig {
|
|
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/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java
|
|
index 4cff831de2128cd346f1f1627f0915d534b0d3bf..0305f3c93e8485552890dd5eca8e79277e2bb886 100644
|
|
--- a/src/main/java/net/minecraft/server/RegionFileCache.java
|
|
+++ b/src/main/java/net/minecraft/server/RegionFileCache.java
|
|
@@ -27,7 +27,7 @@ public final class RegionFileCache implements AutoCloseable {
|
|
if (regionfile != null) {
|
|
return regionfile;
|
|
} else {
|
|
- if (this.cache.size() >= 256) {
|
|
+ if (this.cache.size() >= com.destroystokyo.paper.PaperConfig.regionFileCacheSize) { // Paper - configurable
|
|
((RegionFile) this.cache.removeLast()).close();
|
|
}
|
|
|