balance lru capacity with respect to the number of currently loaded sections

This commit is contained in:
mcrcortex
2025-10-25 19:35:32 +10:00
parent d2a5b1e607
commit c739e545f2

View File

@@ -113,12 +113,22 @@ public class ActiveSectionTracker {
long stamp2 = lock.readLock();
long stamp = this.lruLock.writeLock();
section = this.lruSecondaryCache.remove(key);
WorldSection removal = null;
if (section == null && this.lruSize+100<this.lruSecondaryCache.size()+this.getLoadedCacheCount()) {//Add a self clamping lru case for when there are alot of loaded sections
removal = this.lruSecondaryCache.removeFirst();
}
this.lruLock.unlockWrite(stamp);
if (section != null) {
section.primeForReuse();
section.acquire(1);
}
lock.unlockRead(stamp2);
if (removal != null) {
removal._releaseArray();
}
} else {
VolatileHolder.PRE_ACQUIRE_COUNT.getAndAdd(holder, 1);
}