Paper/Spigot-Server-Patches/0075-Sanitise-RegionFileCache-and-make-configurable.patch

40 lines
2.0 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2019-04-27 05:05:36 +02:00
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 436e555205327afcb8e294370810cf27f8a21dd7..772f48ca940b235481dd27669d9370e53f5380dd 100644
2019-04-27 05:05:36 +02:00
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -222,4 +222,9 @@ public class PaperConfig {
2019-04-27 05:05:36 +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);
2019-04-27 05:05:36 +02:00
+ }
}
diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java
index 26fabb4e5d3945ace851cf6e4474e91611c45b1d..6be04e230fe96c1f2345a00de4f648d9eb712a82 100644
2019-04-27 05:05:36 +02:00
--- a/src/main/java/net/minecraft/server/RegionFileCache.java
+++ b/src/main/java/net/minecraft/server/RegionFileCache.java
@@ -28,7 +28,7 @@ public final class RegionFileCache implements AutoCloseable {
2019-04-27 05:05:36 +02:00
if (regionfile != null) {
return regionfile;
} else {
- if (this.cache.size() >= 256) {
2019-12-11 03:43:21 +01:00
+ if (this.cache.size() >= com.destroystokyo.paper.PaperConfig.regionFileCacheSize) { // Paper - configurable
2019-05-28 01:01:45 +02:00
((RegionFile) this.cache.removeLast()).close();
2019-04-27 05:05:36 +02:00
}