This commit is contained in:
RePixelatedMC
2023-11-15 11:14:26 +01:00
parent 7a729c39a6
commit 4e4f7f693d
6 changed files with 37 additions and 17 deletions

View File

@@ -141,6 +141,7 @@ public class IrisSettings {
public int resourceLoaderCacheSize = 1_024;
public int objectLoaderCacheSize = 4_096;
public int scriptLoaderCacheSize = 512;
public boolean dynamicPerformanceMode = true;
}
@Data

View File

@@ -53,10 +53,12 @@ public class CommandDeveloper implements DecreeExecutor {
Iris.info("-------------------------");
Iris.info(C.DARK_PURPLE + "Engine Status");
Iris.info(C.DARK_PURPLE + "Tectonic Limit: " + C.LIGHT_PURPLE + engine.getMantle().getTectonicLimit());
Iris.info(C.DARK_PURPLE + "Tectonic Plates: " + C.LIGHT_PURPLE + engine.getMantle().getLoadedRegionCount());
Iris.info(C.DARK_PURPLE + "Tectonic ToUnload: " + C.LIGHT_PURPLE + outputToUnload);
Iris.info(C.DARK_PURPLE + "Tectonic Unload Duration: " + C.LIGHT_PURPLE + Form.duration(engine.getMantle().getTectonicDuration()));
Iris.info(C.DARK_PURPLE + "Cache Size: " + C.LIGHT_PURPLE + Form.f(IrisData.cacheSize()));
Iris.info(C.DARK_PURPLE + "LastUse Size: " + C.LIGHT_PURPLE + Form.mem(lastUseSize) + " MB");
Iris.info(C.DARK_PURPLE + "LastUse Size: " + C.LIGHT_PURPLE + Form.mem(lastUseSize));
Iris.info("-------------------------");
} else {
Iris.info(C.RED + "Engine is null!");

View File

@@ -7,7 +7,6 @@ import oshi.hardware.GlobalMemory;
import static com.volmit.iris.util.misc.getHardware.*;
public class PerformanceSFG {
public static boolean lowPerformance = false;
public static void calculatePerformance(){

View File

@@ -290,15 +290,10 @@ public class IrisEngineMantle implements EngineMantle {
x = 4;
Iris.info("Mantle Size: " + x + " Chunks " + C.BLUE + "BENCHMARK MODE");
} else {
if(lowPerformance){
x = 4;
Iris.info("Mantle Size: " + x + " Chunks" + C.GOLD + "LOW PERFORMANCE MODE");
} else {
Iris.info("Mantle Size: " + x + " Chunks");
Iris.info(" Object Mantle Size: " + u + " (" + ((Math.max(u, 16) + 16) >> 4) + ")");
Iris.info(" Jigsaw Mantle Size: " + jig + " (" + ((Math.max(jig, 16) + 16) >> 4) + ")");
Iris.info(" Carving Mantle Size: " + c + " (" + ((Math.max(c, 16) + 16) >> 4) + ")");
}
Iris.info("Mantle Size: " + x + " Chunks");
Iris.info(" Object Mantle Size: " + u + " (" + ((Math.max(u, 16) + 16) >> 4) + ")");
Iris.info(" Jigsaw Mantle Size: " + jig + " (" + ((Math.max(jig, 16) + 16) >> 4) + ")");
Iris.info(" Carving Mantle Size: " + c + " (" + ((Math.max(c, 16) + 16) >> 4) + ")");
}

View File

@@ -295,4 +295,10 @@ public interface EngineMantle extends IObjectPlacer {
default long getToUnload(){
return getMantle().ToUnloadTectonic();
}
default long getTectonicLimit(){
return getTectonicLimit();
}
default long getTectonicDuration(){
return getMantle().getTectonicUnloadDuration();
}
}

View File

@@ -18,6 +18,7 @@
package com.volmit.iris.util.mantle;
import com.google.common.util.concurrent.AtomicDouble;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.tools.IrisToolbelt;
@@ -73,7 +74,6 @@ public class Mantle {
long apm = getHardware.getAvailableProcessMemory();
private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
int tectonicLimitBeforeOutMemory;
double tectonicLimit = 30;
/**
* Create a new mantle
@@ -400,29 +400,43 @@ public class Mantle {
*
* @param baseIdleDuration the duration
*/
@Getter
AtomicInteger FakeToUnload = new AtomicInteger(0);
AtomicDouble adjustedIdleDuration = new AtomicDouble(0);
double tectonicLimit = 30;
public synchronized void trim(long baseIdleDuration) {
if (closed.get()) {
throw new RuntimeException("The Mantle is closed");
}
if (IrisSettings.get().getPerformance().dynamicPerformanceMode){
tectonicLimit = 2;
long t = getHardware.getProcessMemory();
for (; t > 250;){
tectonicLimit++;
t = t - 250;
}
double adjustedIdleDuration = baseIdleDuration;
}
adjustedIdleDuration.set(baseIdleDuration);
if (loadedRegions.size() > tectonicLimit) {
adjustedIdleDuration = Math.max(adjustedIdleDuration - (1000 * (loadedRegions.size() - tectonicLimit) * 1.35), 4000);
adjustedIdleDuration.set(Math.max(adjustedIdleDuration.get() - (1000 * (loadedRegions.size() - tectonicLimit) * 1.35), 4000));
if (getHardware.getProcessMemory() < 5000 && IrisSettings.get().getPerformance().dynamicPerformanceMode) {
adjustedIdleDuration.set(Math.max(adjustedIdleDuration.get() - (1000 * (loadedRegions.size() - tectonicLimit) * 2.65), 4000));
}
}
io.set(true);
try {
Iris.debug("Trimming Tectonic Plates older than " + Form.duration(adjustedIdleDuration, 0));
Iris.debug("Trimming Tectonic Plates older than " + Form.duration(adjustedIdleDuration.get(), 0));
Set<Long> toUnload = new HashSet<>();
for (Long i : lastUse.keySet()) {
double finalAdjustedIdleDuration = adjustedIdleDuration;
double finalAdjustedIdleDuration = adjustedIdleDuration.get();
hyperLock.withLong(i, () -> {
if (M.ms() - lastUse.get(i) >= finalAdjustedIdleDuration) {
toUnload.add(i);
@@ -463,6 +477,9 @@ public class Mantle {
public long ToUnloadTectonic(){
return FakeToUnload.get();
}
public double getTectonicUnloadDuration(){
return adjustedIdleDuration.get();
}
/**