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.
This commit is contained in:
Antony Riley 2016-03-29 08:22:55 +03:00
parent c801c5439d
commit db2502d732

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
+++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
@@ -32,8 +32,8 @@
@@ -32,21 +32,22 @@
this.info = storageKey;
}
@ -11,7 +11,12 @@
RegionFile regionfile = (RegionFile) this.regionCache.getAndMoveToFirst(i);
if (regionfile != null) {
@@ -45,8 +45,9 @@
return regionfile;
} else {
- if (this.regionCache.size() >= 256) {
+ if (this.regionCache.size() >= io.papermc.paper.configuration.GlobalConfiguration.get().misc.regionFileCacheSize) { // Paper - Sanitise RegionFileCache and make configurable
((RegionFile) this.regionCache.removeLast()).close();
}
FileUtil.createDirectoriesSafe(this.folder);
Path path = this.folder;