mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-25 08:38:45 +01:00
b62dfa0bf9
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 39ce5d3a SPIGOT-4399: ItemMeta.equals broken with AttributeModifiers CraftBukkit Changes:1cf8b5dc
SPIGOT-4400: Populators running on existing chunks116cb9a1
SPIGOT-4399: Add attribute modifier equality test5ee1c18a
SPIGOT-4398: Set ASM7_EXPERIMENTAL flag
81 lines
3.3 KiB
Diff
81 lines
3.3 KiB
Diff
From 7d5b2bb1ce854b24a8ef1ec40574698774fb70f6 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 88c465ef1c..121a87662c 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
@@ -219,4 +219,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 = getInt("settings.region-file-cache-size", 256);
|
|
+ }
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java
|
|
index 2217adf99c..c0ab543b91 100644
|
|
--- a/src/main/java/net/minecraft/server/RegionFileCache.java
|
|
+++ b/src/main/java/net/minecraft/server/RegionFileCache.java
|
|
@@ -9,10 +9,12 @@ import java.io.IOException;
|
|
import java.util.Iterator;
|
|
import java.util.Map;
|
|
import javax.annotation.Nullable;
|
|
+import com.destroystokyo.paper.PaperConfig; // Paper
|
|
+import java.util.LinkedHashMap; // Paper
|
|
|
|
public class RegionFileCache {
|
|
|
|
- public static final Map<File, RegionFile> a = Maps.newHashMap(); // Spigot - private -> public
|
|
+ public static final Map<File, RegionFile> a = new LinkedHashMap(PaperConfig.regionFileCacheSize, 0.75f, true); // Spigot - private -> public, Paper - HashMap -> LinkedHashMap
|
|
|
|
public static synchronized RegionFile a(File file, int i, int j) {
|
|
File file1 = new File(file, "region");
|
|
@@ -26,8 +28,8 @@ public class RegionFileCache {
|
|
file1.mkdirs();
|
|
}
|
|
|
|
- if (RegionFileCache.a.size() >= 256) {
|
|
- a();
|
|
+ if (RegionFileCache.a.size() >= PaperConfig.regionFileCacheSize) { // Paper
|
|
+ trimCache(); // Paper
|
|
}
|
|
|
|
RegionFile regionfile1 = new RegionFile(file2);
|
|
@@ -60,6 +62,22 @@ public class RegionFileCache {
|
|
}
|
|
// CraftBukkit end
|
|
|
|
+ // Paper Start
|
|
+ private static synchronized void trimCache() {
|
|
+ Iterator<Map.Entry<File, RegionFile>> itr = RegionFileCache.a.entrySet().iterator();
|
|
+ int count = RegionFileCache.a.size() - PaperConfig.regionFileCacheSize;
|
|
+ while (count-- >= 0 && itr.hasNext()) {
|
|
+ try {
|
|
+ itr.next().getValue().c();
|
|
+ } catch (IOException ioexception) {
|
|
+ ioexception.printStackTrace();
|
|
+ ServerInternalException.reportInternalException(ioexception);
|
|
+ }
|
|
+ itr.remove();
|
|
+ }
|
|
+ }
|
|
+ // Paper End
|
|
+
|
|
public static synchronized void a() {
|
|
Iterator iterator = RegionFileCache.a.values().iterator();
|
|
|
|
--
|
|
2.19.0
|
|
|