mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-06-18 14:50:57 +00:00
FINALLY
This commit is contained in:
@@ -34,7 +34,7 @@ public class DynamicPerformanceSVC implements IrisService {
|
|||||||
try {
|
try {
|
||||||
if (engine.getMantle().getTectonicLimit() < engine.getMantle().getLoadedRegionCount()){
|
if (engine.getMantle().getTectonicLimit() < engine.getMantle().getLoadedRegionCount()){
|
||||||
// engine.getMantle().trim(5);
|
// engine.getMantle().trim(5);
|
||||||
return 2000;
|
// return 2000;
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Iris.reportError(e);
|
Iris.reportError(e);
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ import com.volmit.iris.util.parallel.HyperLock;
|
|||||||
import com.volmit.iris.util.parallel.MultiBurst;
|
import com.volmit.iris.util.parallel.MultiBurst;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.checkerframework.checker.units.qual.A;
|
|
||||||
|
|
||||||
import java.io.EOFException;
|
import java.io.EOFException;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -415,10 +414,10 @@ public class Mantle {
|
|||||||
if (closed.get()) {
|
if (closed.get()) {
|
||||||
throw new RuntimeException("The Mantle is closed");
|
throw new RuntimeException("The Mantle is closed");
|
||||||
}
|
}
|
||||||
if (forceAggressiveThreshold.get() != -1) {
|
if (IrisSettings.get().getPerformance().getAggressiveTectonicThreshold() == -1) {
|
||||||
forceAggressiveThreshold.set(IrisSettings.get().getPerformance().getAggressiveTectonicThreshold());
|
|
||||||
} else {
|
|
||||||
forceAggressiveThreshold.set(tectonicLimit.get());
|
forceAggressiveThreshold.set(tectonicLimit.get());
|
||||||
|
} else {
|
||||||
|
forceAggressiveThreshold.set(IrisSettings.get().getPerformance().getAggressiveTectonicThreshold());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(IrisSettings.get().getPerformance().dynamicPerformanceMode) {
|
if(IrisSettings.get().getPerformance().dynamicPerformanceMode) {
|
||||||
@@ -431,8 +430,10 @@ public class Mantle {
|
|||||||
dynamicThreads.addAndGet(1);
|
dynamicThreads.addAndGet(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (g > 0) {
|
||||||
g--;
|
g--;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (dynamicThreads.get() >= 2) {
|
if (dynamicThreads.get() >= 2) {
|
||||||
dynamicThreads.addAndGet(-1);
|
dynamicThreads.addAndGet(-1);
|
||||||
@@ -478,11 +479,14 @@ public class Mantle {
|
|||||||
if (IrisSettings.get().getPerformance().AggressiveTectonicUnload
|
if (IrisSettings.get().getPerformance().AggressiveTectonicUnload
|
||||||
&& loadedRegions.size() > forceAggressiveThreshold.get()) {
|
&& loadedRegions.size() > forceAggressiveThreshold.get()) {
|
||||||
|
|
||||||
while (loadedRegions.size() > tectonicLimit.get()) {
|
AtomicInteger dummyLoadedRegions = new AtomicInteger(loadedRegions.size());
|
||||||
|
|
||||||
|
while (dummyLoadedRegions.get() > tectonicLimit.get()) {
|
||||||
Long[] oldestKey = {null};
|
Long[] oldestKey = {null};
|
||||||
long[] oldestAge = {Long.MIN_VALUE};
|
long[] oldestAge = {Long.MIN_VALUE};
|
||||||
|
|
||||||
for (Long key : lastUse.keySet()) {
|
for (Long key : lastUse.keySet()) {
|
||||||
|
hyperLock.withLong(key, () -> {
|
||||||
if (!toUnload.contains(key)) {
|
if (!toUnload.contains(key)) {
|
||||||
long age = M.ms() - lastUse.get(key);
|
long age = M.ms() - lastUse.get(key);
|
||||||
if (age > oldestAge[0]) {
|
if (age > oldestAge[0]) {
|
||||||
@@ -490,6 +494,7 @@ public class Mantle {
|
|||||||
oldestKey[0] = key;
|
oldestKey[0] = key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldestKey[0] != null) {
|
if (oldestKey[0] != null) {
|
||||||
@@ -497,15 +502,14 @@ public class Mantle {
|
|||||||
hyperLock.withLong(finalOldestKey, () -> {
|
hyperLock.withLong(finalOldestKey, () -> {
|
||||||
toUnload.add(finalOldestKey);
|
toUnload.add(finalOldestKey);
|
||||||
Iris.debug("Oldest Tectonic Region " + finalOldestKey + " added to unload");
|
Iris.debug("Oldest Tectonic Region " + finalOldestKey + " added to unload");
|
||||||
|
dummyLoadedRegions.getAndDecrement();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BurstExecutor burstExecutor = new BurstExecutor(Executors.newFixedThreadPool(dynamicThreads.get()), toUnload.size());
|
BurstExecutor burstExecutor = new BurstExecutor(Executors.newFixedThreadPool(dynamicThreads.get()), toUnload.size());
|
||||||
|
for (Long i : toUnload.toArray(Long[]::new)) {
|
||||||
for (Long i : toUnload) {
|
|
||||||
burstExecutor.queue(() -> {
|
burstExecutor.queue(() -> {
|
||||||
hyperLock.withLong(i, () -> {
|
hyperLock.withLong(i, () -> {
|
||||||
TectonicPlate m = loadedRegions.get(i);
|
TectonicPlate m = loadedRegions.get(i);
|
||||||
@@ -514,6 +518,7 @@ public class Mantle {
|
|||||||
m.write(fileForRegion(dataFolder, i));
|
m.write(fileForRegion(dataFolder, i));
|
||||||
loadedRegions.remove(i);
|
loadedRegions.remove(i);
|
||||||
lastUse.remove(i);
|
lastUse.remove(i);
|
||||||
|
toUnload.remove(i);
|
||||||
Iris.debug("Unloaded Tectonic Plate " + C.DARK_GREEN + Cache.keyX(i) + " " + Cache.keyZ(i));
|
Iris.debug("Unloaded Tectonic Plate " + C.DARK_GREEN + Cache.keyX(i) + " " + Cache.keyZ(i));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
Reference in New Issue
Block a user