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
2024-01-23 14:34:17 +01:00
Subject: [PATCH] Sanitise RegionFileCache and make configurable
2021-06-11 14:02:28 +02:00
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/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
2024-11-29 02:39:40 +01:00
index 40f2f4d052add3b4270d29c843e49fb621e1bc8d..54803d561d98b0d3fd8aa2060a7a184a00dd9da6 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
2024-06-15 02:19:25 +02:00
@@ -39,7 +39,7 @@ public final class RegionFileStorage implements AutoCloseable {
2024-01-24 13:07:40 +01:00
if (regionfile != null) {
return regionfile;
} else {
2021-06-11 14:02:28 +02:00
- if (this.regionCache.size() >= 256) {
2024-01-24 13:07:40 +01:00
+ if (this.regionCache.size() >= io.papermc.paper.configuration.GlobalConfiguration.get().misc.regionFileCacheSize) { // Paper - Sanitise RegionFileCache and make configurable
2021-06-11 14:02:28 +02:00
((RegionFile) this.regionCache.removeLast()).close();
}