2020-05-06 09:48:49 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2019-04-27 03:05:36 +00: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
|
2021-02-26 17:54:48 +00:00
|
|
|
index 716f285e67019b8a62922d09c15883c99f9421aa..439dcc6effdc91830d2b7ede9063982998b37120 100644
|
2019-04-27 03:05:36 +00:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
2021-02-26 17:54:48 +00:00
|
|
|
@@ -227,4 +227,9 @@ public class PaperConfig {
|
2019-04-27 03:05:36 +00:00
|
|
|
private static void loadPermsBeforePlugins() {
|
|
|
|
loadPermsBeforePlugins = getBoolean("settings.load-permissions-yml-before-plugins", true);
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ public static int regionFileCacheSize = 256;
|
|
|
|
+ private static void regionFileCacheSize() {
|
2019-06-17 03:52:34 +00:00
|
|
|
+ regionFileCacheSize = Math.max(getInt("settings.region-file-cache-size", 256), 4);
|
2019-04-27 03:05:36 +00:00
|
|
|
+ }
|
|
|
|
}
|
2021-03-16 07:19:45 +00:00
|
|
|
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
|
2021-03-16 13:04:28 +00:00
|
|
|
index 8310dd6bfc04b8ac0a51545baa3a264e6cb42eac..75b10a3755392870d8f5b51239a09a0e7fd75a42 100644
|
2021-03-16 07:19:45 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileCache.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileCache.java
|
2021-03-16 13:04:28 +00:00
|
|
|
@@ -33,7 +33,7 @@ public final class RegionFileCache implements AutoCloseable {
|
2019-04-27 03:05:36 +00:00
|
|
|
if (regionfile != null) {
|
|
|
|
return regionfile;
|
|
|
|
} else {
|
|
|
|
- if (this.cache.size() >= 256) {
|
2019-12-11 02:43:21 +00:00
|
|
|
+ if (this.cache.size() >= com.destroystokyo.paper.PaperConfig.regionFileCacheSize) { // Paper - configurable
|
2019-05-27 23:01:45 +00:00
|
|
|
((RegionFile) this.cache.removeLast()).close();
|
2019-04-27 03:05:36 +00:00
|
|
|
}
|
|
|
|
|