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:
@@ -1,6 +1,6 @@
|
|||||||
--- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
--- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||||
+++ b/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;
|
this.info = storageKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -11,7 +11,12 @@
|
|||||||
RegionFile regionfile = (RegionFile) this.regionCache.getAndMoveToFirst(i);
|
RegionFile regionfile = (RegionFile) this.regionCache.getAndMoveToFirst(i);
|
||||||
|
|
||||||
if (regionfile != null) {
|
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);
|
FileUtil.createDirectoriesSafe(this.folder);
|
||||||
Path path = this.folder;
|
Path path = this.folder;
|
||||||
|
|||||||
Reference in New Issue
Block a user