mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-06-17 14:21:33 +00:00
So now it actually it works
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
package com.volmit.iris.core.commands;
|
package com.volmit.iris.core.commands;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.core.IrisSettings;
|
||||||
import com.volmit.iris.core.loader.IrisData;
|
import com.volmit.iris.core.loader.IrisData;
|
||||||
import com.volmit.iris.core.tools.IrisToolbelt;
|
import com.volmit.iris.core.tools.IrisToolbelt;
|
||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
@@ -61,6 +62,7 @@ public class CommandDeveloper implements DecreeExecutor {
|
|||||||
Iris.info(C.DARK_PURPLE + "Tectonic Unload Duration: " + C.LIGHT_PURPLE + Form.duration((long) engine.getMantle().getTectonicDuration()));
|
Iris.info(C.DARK_PURPLE + "Tectonic Unload Duration: " + C.LIGHT_PURPLE + Form.duration((long) engine.getMantle().getTectonicDuration()));
|
||||||
Iris.info(C.DARK_PURPLE + "Cache Size: " + C.LIGHT_PURPLE + Form.f(IrisData.cacheSize()));
|
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));
|
Iris.info(C.DARK_PURPLE + "LastUse Size: " + C.LIGHT_PURPLE + Form.mem(lastUseSize));
|
||||||
|
Iris.info(C.DARK_PURPLE + "Agressive Unload: " + C.LIGHT_PURPLE + IrisSettings.get().getPerformance().AggressiveTectonicUnload);
|
||||||
Iris.info("-------------------------");
|
Iris.info("-------------------------");
|
||||||
} else {
|
} else {
|
||||||
Iris.info(C.RED + "Engine is null!");
|
Iris.info(C.RED + "Engine is null!");
|
||||||
|
|||||||
@@ -1,33 +1,15 @@
|
|||||||
package com.volmit.iris.core.service;
|
package com.volmit.iris.core.service;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.google.gson.JsonParseException;
|
|
||||||
import com.google.gson.JsonParser;
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.core.IrisSettings;
|
import com.volmit.iris.core.IrisSettings;
|
||||||
import com.volmit.iris.core.tools.IrisToolbelt;
|
|
||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
import com.volmit.iris.util.SFG.WorldHandlerSFG;
|
|
||||||
import com.volmit.iris.util.format.C;
|
|
||||||
import com.volmit.iris.util.mantle.Mantle;
|
import com.volmit.iris.util.mantle.Mantle;
|
||||||
import com.volmit.iris.util.math.M;
|
|
||||||
import com.volmit.iris.util.misc.getHardware;
|
import com.volmit.iris.util.misc.getHardware;
|
||||||
import com.volmit.iris.util.plugin.IrisService;
|
import com.volmit.iris.util.plugin.IrisService;
|
||||||
import com.volmit.iris.util.scheduling.Looper;
|
import com.volmit.iris.util.scheduling.Looper;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
import static com.volmit.iris.util.mantle.Mantle.tectonicLimit;
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.*;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import static com.volmit.iris.util.mantle.Mantle.*;
|
|
||||||
import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE;
|
|
||||||
|
|
||||||
public class DynamicPerformanceSVC implements IrisService {
|
public class DynamicPerformanceSVC implements IrisService {
|
||||||
private JavaPlugin plugin;
|
private JavaPlugin plugin;
|
||||||
@@ -50,7 +32,10 @@ public class DynamicPerformanceSVC implements IrisService {
|
|||||||
@Override
|
@Override
|
||||||
protected long loop() {
|
protected long loop() {
|
||||||
try {
|
try {
|
||||||
|
if (engine.getMantle().getTectonicLimit() < engine.getMantle().getLoadedRegionCount()){
|
||||||
|
engine.getMantle().trim(5);
|
||||||
|
return 2000;
|
||||||
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Iris.reportError(e);
|
Iris.reportError(e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -69,7 +54,7 @@ public class DynamicPerformanceSVC implements IrisService {
|
|||||||
tectonicLimit.getAndAdd(1);
|
tectonicLimit.getAndAdd(1);
|
||||||
t = t - 250;
|
t = t - 250;
|
||||||
}
|
}
|
||||||
// tectonicLimit.set(10);
|
tectonicLimit.set(10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,17 +42,16 @@ 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;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Comparator;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The mantle can store any type of data slice anywhere and manage regions & IO on it's own.
|
* The mantle can store any type of data slice anywhere and manage regions & IO on it's own.
|
||||||
@@ -400,6 +399,8 @@ public class Mantle {
|
|||||||
private final AtomicInteger dynamicThreads = new AtomicInteger(1);
|
private final AtomicInteger dynamicThreads = new AtomicInteger(1);
|
||||||
@Getter
|
@Getter
|
||||||
private final AtomicInteger forceAggressiveThreshold = new AtomicInteger(30);
|
private final AtomicInteger forceAggressiveThreshold = new AtomicInteger(30);
|
||||||
|
@Getter
|
||||||
|
private final AtomicLong oldestTectonicPlate = new AtomicLong(0);
|
||||||
private int g = 0;
|
private int g = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -412,7 +413,7 @@ 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 (forceAggressiveThreshold.get() != -1) {
|
||||||
forceAggressiveThreshold.set(IrisSettings.get().getPerformance().getAggressiveTectonicThreshold());
|
forceAggressiveThreshold.set(IrisSettings.get().getPerformance().getAggressiveTectonicThreshold());
|
||||||
} else {
|
} else {
|
||||||
forceAggressiveThreshold.set(tectonicLimit.get());
|
forceAggressiveThreshold.set(tectonicLimit.get());
|
||||||
@@ -473,30 +474,34 @@ public class Mantle {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IrisSettings.get().getPerformance().AggressiveTectonicUnload && loadedRegions.size() > tectonicLimit.get() && tectonicLimit.get() > forceAggressiveThreshold.get()) {
|
if (IrisSettings.get().getPerformance().AggressiveTectonicUnload
|
||||||
AtomicInteger dummyLoadedRegions = new AtomicInteger(loadedRegions.size());
|
&& loadedRegions.size() > forceAggressiveThreshold.get()) {
|
||||||
|
|
||||||
while (dummyLoadedRegions.get() > tectonicLimit.get()) {
|
while (loadedRegions.size() > tectonicLimit.get()) {
|
||||||
try {
|
Long[] oldestKey = {null};
|
||||||
long fiveSecondsAgo = M.ms() - 5000;
|
long[] oldestAge = {Long.MIN_VALUE};
|
||||||
toUnload.clear();
|
|
||||||
|
|
||||||
lastUse.entrySet().stream()
|
for (Long key : lastUse.keySet()) {
|
||||||
.filter(e -> e.getValue() < fiveSecondsAgo)
|
long age = M.ms() - lastUse.get(key);
|
||||||
.max(Comparator.comparingLong(Map.Entry::getValue))
|
if (age > oldestAge[0]) {
|
||||||
.map(Map.Entry::getKey)
|
oldestAge[0] = age;
|
||||||
.ifPresent(oldestOverFiveSeconds -> hyperLock.withLong(oldestOverFiveSeconds, () -> {
|
oldestKey[0] = key;
|
||||||
if (M.ms() - lastUse.get(oldestOverFiveSeconds) >= adjustedIdleDuration.get()) {
|
}
|
||||||
toUnload.add(oldestOverFiveSeconds);
|
}
|
||||||
fakeToUnload.getAndAdd(1);
|
|
||||||
Iris.debug("Oldest Tectonic Region over 5 seconds idle added to unload");
|
|
||||||
dummyLoadedRegions.getAndDecrement();
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
if (oldestKey[0] != null) {
|
||||||
|
Long finalOldestKey = oldestKey[0]; // Create a final variable for use in the lambda
|
||||||
|
hyperLock.withLong(finalOldestKey, () -> {
|
||||||
|
toUnload.add(finalOldestKey);
|
||||||
|
fakeToUnload.addAndGet(1);
|
||||||
|
Iris.info("Oldest Tectonic Region " + finalOldestKey + " added to unload");
|
||||||
|
|
||||||
|
// Remove the region from loadedRegions and lastUse
|
||||||
|
loadedRegions.remove(finalOldestKey);
|
||||||
|
lastUse.remove(finalOldestKey);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user