aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0081-Sanitise-RegionFileCache-and-make-configurable.patch
blob: 077dc7b91949d8b997bd3197ab4fbade38f10a02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
index a16047cab2709d197489215de66bf24901523a1c..4c1b1ac36ef09a9cc8da6e8ee71f82d4a67478df 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
@@ -91,7 +91,7 @@ public class RegionFileStorage implements AutoCloseable {
                 return null;
             }
             // Paper end - cache regionfile does not exist state
-            if (this.regionCache.size() >= 256) {
+            if (this.regionCache.size() >= io.papermc.paper.configuration.GlobalConfiguration.get().misc.regionFileCacheSize) { // Paper - configurable
                 ((RegionFile) this.regionCache.removeLast()).close();
             }