mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-06-17 14:21:33 +00:00
smth like this
This commit is contained in:
@@ -141,8 +141,10 @@ public class IrisSettings {
|
|||||||
public int resourceLoaderCacheSize = 1_024;
|
public int resourceLoaderCacheSize = 1_024;
|
||||||
public int objectLoaderCacheSize = 4_096;
|
public int objectLoaderCacheSize = 4_096;
|
||||||
public int scriptLoaderCacheSize = 512;
|
public int scriptLoaderCacheSize = 512;
|
||||||
public int tectonicUnloadThreads = 1;
|
public int tectonicUnloadThreads = -1; // -1 = Disabled and instead use the dynamic method
|
||||||
public boolean dynamicPerformanceMode = true;
|
public boolean dynamicPerformanceMode = true;
|
||||||
|
public boolean AggressiveTectonicUnload = false;
|
||||||
|
public int AggressiveTectonicThreshold = -1; // -1 = Disabled and instead uses the tectonicLimit
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ public class CommandDeveloper implements DecreeExecutor {
|
|||||||
|
|
||||||
Iris.info("-------------------------");
|
Iris.info("-------------------------");
|
||||||
Iris.info(C.DARK_PURPLE + "Engine Status");
|
Iris.info(C.DARK_PURPLE + "Engine Status");
|
||||||
|
Iris.info(C.DARK_PURPLE + "Tectonic Threads: " + C.LIGHT_PURPLE + engine.getMantle().getDynamicThreads());
|
||||||
Iris.info(C.DARK_PURPLE + "Tectonic Limit: " + C.LIGHT_PURPLE + engine.getMantle().getTectonicLimit());
|
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 Plates: " + C.LIGHT_PURPLE + engine.getMantle().getLoadedRegionCount());
|
||||||
Iris.info(C.DARK_PURPLE + "Tectonic ToUnload: " + C.LIGHT_PURPLE + engine.getMantle().getToUnload());
|
Iris.info(C.DARK_PURPLE + "Tectonic ToUnload: " + C.LIGHT_PURPLE + engine.getMantle().getToUnload());
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ public class DynamicPerformanceSVC implements IrisService {
|
|||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
this.plugin = Iris.instance;
|
this.plugin = Iris.instance;
|
||||||
if (IrisSettings.get().getPerformance().dynamicPerformanceMode) {
|
if (IrisSettings.get().getPerformance().dynamicPerformanceMode) {
|
||||||
Iris.info("Enabled DynamicPerformance");
|
|
||||||
this.startupPerformance();
|
this.startupPerformance();
|
||||||
this.DynamicPerformance();
|
this.DynamicPerformance();
|
||||||
ticker.start();
|
ticker.start();
|
||||||
@@ -52,7 +51,6 @@ public class DynamicPerformanceSVC implements IrisService {
|
|||||||
protected long loop() {
|
protected long loop() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Iris.reportError(e);
|
Iris.reportError(e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -71,7 +69,7 @@ public class DynamicPerformanceSVC implements IrisService {
|
|||||||
tectonicLimit.getAndAdd(1);
|
tectonicLimit.getAndAdd(1);
|
||||||
t = t - 250;
|
t = t - 250;
|
||||||
}
|
}
|
||||||
//tectonicLimit.set(10);
|
tectonicLimit.set(10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -293,7 +293,10 @@ public interface EngineMantle extends IObjectPlacer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default long getToUnload(){
|
default long getToUnload(){
|
||||||
return Mantle.FakeToUnload.get();
|
return Mantle.fakeToUnload.get();
|
||||||
|
}
|
||||||
|
default long getDynamicThreads(){
|
||||||
|
return Mantle.dynamicThreads.get();
|
||||||
}
|
}
|
||||||
default double getTectonicLimit(){
|
default double getTectonicLimit(){
|
||||||
return getMantle().tectonicLimit.get();
|
return getMantle().tectonicLimit.get();
|
||||||
|
|||||||
@@ -397,15 +397,53 @@ public class Mantle {
|
|||||||
* @param baseIdleDuration the duration
|
* @param baseIdleDuration the duration
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static AtomicInteger FakeToUnload = new AtomicInteger(0);
|
@Getter
|
||||||
|
public static AtomicInteger fakeToUnload = new AtomicInteger(0);
|
||||||
|
public static AtomicInteger oldFakeToUnload = new AtomicInteger((0));
|
||||||
public static AtomicDouble adjustedIdleDuration = new AtomicDouble(0);
|
public static AtomicDouble adjustedIdleDuration = new AtomicDouble(0);
|
||||||
public static AtomicInteger tectonicLimit = new AtomicInteger(30);
|
public static AtomicInteger tectonicLimit = new AtomicInteger(30);
|
||||||
|
public static AtomicInteger dynamicThreads = new AtomicInteger(1);
|
||||||
|
public static AtomicInteger forceAggressiveThreshold = new AtomicInteger(30);
|
||||||
|
public int g = 0;
|
||||||
|
|
||||||
|
|
||||||
public synchronized void trim(long baseIdleDuration) {
|
public synchronized void trim(long baseIdleDuration) {
|
||||||
if (closed.get()) {
|
if (closed.get()) {
|
||||||
throw new RuntimeException("The Mantle is closed");
|
throw new RuntimeException("The Mantle is closed");
|
||||||
}
|
}
|
||||||
|
if (forceAggressiveThreshold.get() <= -1) {
|
||||||
|
forceAggressiveThreshold.set(IrisSettings.get().getPerformance().getAggressiveTectonicThreshold());
|
||||||
|
} else {
|
||||||
|
forceAggressiveThreshold.set(tectonicLimit.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(IrisSettings.get().getPerformance().dynamicPerformanceMode) {
|
||||||
|
int h = dynamicThreads.get() - 1;
|
||||||
|
if (fakeToUnload.get() != 0) {
|
||||||
|
if (fakeToUnload.get() > oldFakeToUnload.get()) {
|
||||||
|
g++;
|
||||||
|
if (g >= 2 && IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getParallelism()) > h && IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getParallelism()) != h) {
|
||||||
|
dynamicThreads.addAndGet(1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
g--;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (dynamicThreads.get() >= 2) {
|
||||||
|
dynamicThreads.addAndGet(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
oldFakeToUnload = fakeToUnload;
|
||||||
|
}
|
||||||
|
if (!IrisSettings.get().getPerformance().dynamicPerformanceMode){
|
||||||
|
if(IrisSettings.get().getPerformance().getTectonicUnloadThreads() <= -1){
|
||||||
|
dynamicThreads.set(1);
|
||||||
|
} else {
|
||||||
|
dynamicThreads.set(IrisSettings.get().getPerformance().getTectonicUnloadThreads());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int dth = dynamicThreads.get();
|
||||||
|
|
||||||
adjustedIdleDuration.set(baseIdleDuration);
|
adjustedIdleDuration.set(baseIdleDuration);
|
||||||
|
|
||||||
if (loadedRegions != null) {
|
if (loadedRegions != null) {
|
||||||
@@ -431,14 +469,13 @@ public class Mantle {
|
|||||||
hyperLock.withLong(i, () -> {
|
hyperLock.withLong(i, () -> {
|
||||||
if (M.ms() - lastUse.get(i) >= finalAdjustedIdleDuration) {
|
if (M.ms() - lastUse.get(i) >= finalAdjustedIdleDuration) {
|
||||||
finalToUnload1.add(i);
|
finalToUnload1.add(i);
|
||||||
FakeToUnload.addAndGet(1);
|
fakeToUnload.addAndGet(1);
|
||||||
Iris.debug("Tectonic Region added to unload");
|
Iris.debug("Tectonic Region added to unload");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
if (IrisSettings.get().getPerformance().AggressiveTectonicUnload && loadedRegions.size() > tectonicLimit.get() && tectonicLimit.get() > forceAggressiveThreshold.get()) {
|
||||||
if (loadedRegions.size() > tectonicLimit.get()) {
|
|
||||||
AtomicInteger dummyLoadedRegions = new AtomicInteger(loadedRegions.size());
|
AtomicInteger dummyLoadedRegions = new AtomicInteger(loadedRegions.size());
|
||||||
|
|
||||||
for (; dummyLoadedRegions.get() > tectonicLimit.get();) {
|
for (; dummyLoadedRegions.get() > tectonicLimit.get();) {
|
||||||
@@ -457,7 +494,7 @@ public class Mantle {
|
|||||||
hyperLock.withLong(oldestOverFiveSeconds, () -> {
|
hyperLock.withLong(oldestOverFiveSeconds, () -> {
|
||||||
if (M.ms() - lastUse.get(oldestOverFiveSeconds) >= adjustedIdleDuration.get()) {
|
if (M.ms() - lastUse.get(oldestOverFiveSeconds) >= adjustedIdleDuration.get()) {
|
||||||
finalToUnload.add(oldestOverFiveSeconds);
|
finalToUnload.add(oldestOverFiveSeconds);
|
||||||
FakeToUnload.addAndGet(1);
|
fakeToUnload.getAndAdd(1);
|
||||||
Iris.debug("Oldest Tectonic Region over 5 seconds idle added to unload");
|
Iris.debug("Oldest Tectonic Region over 5 seconds idle added to unload");
|
||||||
dummyLoadedRegions.getAndDecrement();
|
dummyLoadedRegions.getAndDecrement();
|
||||||
}
|
}
|
||||||
@@ -468,13 +505,11 @@ public class Mantle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
BurstExecutor burstExecutor = new BurstExecutor(Executors.newFixedThreadPool(IrisSettings.get().getPerformance().tectonicUnloadThreads), toUnload.size());
|
|
||||||
|
|
||||||
|
// BurstExecutor burstExecutor = new BurstExecutor(Executors.newFixedThreadPool(1), toUnload.size());
|
||||||
|
|
||||||
for (Long i : toUnload) {
|
for (Long i : toUnload) {
|
||||||
burstExecutor.queue(() -> {
|
// burstExecutor.queue(() -> {
|
||||||
hyperLock.withLong(i, () -> {
|
hyperLock.withLong(i, () -> {
|
||||||
TectonicPlate m = loadedRegions.get(i);
|
TectonicPlate m = loadedRegions.get(i);
|
||||||
if (m != null) {
|
if (m != null) {
|
||||||
@@ -482,16 +517,16 @@ 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);
|
||||||
|
fakeToUnload.getAndAdd(-1);
|
||||||
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));
|
||||||
FakeToUnload.addAndGet(-1);
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
burstExecutor.complete();
|
// burstExecutor.complete();
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
io.set(false);
|
io.set(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user