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-06-15 02:19:25 +02:00
index df099d4c7f101f50d40dae99b45c271b02712434..491035aaefff4ee96435ec5d3f9417e28eae0796 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();
}