Paper/Spigot-Server-Patches/0076-Sanitise-RegionFileCache-and-make-configurable.patch
jmp 1718f61bf8 Updated Upstream (CraftBukkit/Spigot)
Doesn't compile yet.

CraftBukkit Changes:
90d6905b Repackage NMS
69cf961d Repackage patches

Spigot Changes:
79d53c28 Repackage NMS
2021-03-18 18:03:22 +01:00

40 Zeilen
2.1 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 716f285e67019b8a62922d09c15883c99f9421aa..439dcc6effdc91830d2b7ede9063982998b37120 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -227,4 +227,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/world/level/chunk/storage/RegionFileCache.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileCache.java
index 44c09e3b8d5abe4fdf9c4a46c21bc82e9dfefa0b..13d0d6e7e03322f20ef5666d5299d26d51d1714c 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileCache.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileCache.java
@@ -32,7 +32,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();
}