- Added /iris what region

- Sort of Fixed EngineStatus
- Added /iris hasAccess
- Added /iris irisworlds/worlds
- Added Some dev commands
- Redid / improved the mantle tectonic unload
- Convert still not working so ignore that
- Cleaned Iris of IrisPackBenchmarking.java im redoing it on second thought.
- Adjusted build.gradle
- Renamed some tectonic stuff
- Perhaps more?
This commit is contained in:
RePixelatedMC 2024-03-16 12:40:40 +01:00
parent 34cad85942
commit 9612fef2a4
12 changed files with 669 additions and 237 deletions

View File

@ -37,7 +37,7 @@ registerCustomOutputTask('Coco', 'D://mcsm/plugins')
registerCustomOutputTask('Strange', 'D://Servers/1.17 Test Server/plugins') registerCustomOutputTask('Strange', 'D://Servers/1.17 Test Server/plugins')
registerCustomOutputTask('Vatuu', 'D://Minecraft/Servers/1.19.4/plugins') registerCustomOutputTask('Vatuu', 'D://Minecraft/Servers/1.19.4/plugins')
registerCustomOutputTask('CrazyDev22', 'C://Users/Julian/Desktop/server/plugins') registerCustomOutputTask('CrazyDev22', 'C://Users/Julian/Desktop/server/plugins')
registerCustomOutputTask('Pixel', 'C://Users/repix/Iris Dimension Engine/Iris Development/plugins') registerCustomOutputTask('Pixel', 'C://Users/repix/Iris Dimension Engine/1.20.4 - Iris Development/plugins')
// ========================== UNIX ============================== // ========================== UNIX ==============================
registerCustomOutputTaskUnix('CyberpwnLT', '/Users/danielmills/development/server/plugins') registerCustomOutputTaskUnix('CyberpwnLT', '/Users/danielmills/development/server/plugins')
registerCustomOutputTaskUnix('PsychoLT', '/Volumes/PRO-G40/Minecraft/MinecraftDevelopment/Server/plugins') registerCustomOutputTaskUnix('PsychoLT', '/Volumes/PRO-G40/Minecraft/MinecraftDevelopment/Server/plugins')
@ -246,7 +246,7 @@ allprojects {
compileOnly 'org.zeroturnaround:zt-zip:1.14' compileOnly 'org.zeroturnaround:zt-zip:1.14'
compileOnly 'com.google.code.gson:gson:2.9.0' compileOnly 'com.google.code.gson:gson:2.9.0'
compileOnly 'org.ow2.asm:asm:9.2' compileOnly 'org.ow2.asm:asm:9.2'
compileOnly 'com.google.guava:guava:31.1-jre' compileOnly 'com.google.guava:guava:33.0.0-jre'
compileOnly 'bsf:bsf:2.4.0' compileOnly 'bsf:bsf:2.4.0'
compileOnly 'rhino:js:1.7R2' compileOnly 'rhino:js:1.7R2'
compileOnly 'com.github.ben-manes.caffeine:caffeine:3.0.6' compileOnly 'com.github.ben-manes.caffeine:caffeine:3.0.6'

View File

@ -38,9 +38,13 @@ import net.jpountz.lz4.LZ4FrameInputStream;
import net.jpountz.lz4.LZ4FrameOutputStream; import net.jpountz.lz4.LZ4FrameOutputStream;
import org.apache.commons.lang.RandomStringUtils; import org.apache.commons.lang.RandomStringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.World; import org.bukkit.World;
import java.io.*; import java.io.*;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.*;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
@ -51,33 +55,119 @@ public class CommandDeveloper implements DecreeExecutor {
private CommandTurboPregen turboPregen; private CommandTurboPregen turboPregen;
@Decree(description = "Get Loaded TectonicPlates Count", origin = DecreeOrigin.BOTH, sync = true) @Decree(description = "Get Loaded TectonicPlates Count", origin = DecreeOrigin.BOTH, sync = true)
public void EngineStatus( public void EngineStatus() {
@Param(description = "World") List<World> IrisWorlds = new ArrayList<>();
World world int TotalLoadedChunks = 0;
) { int TotalQueuedTectonicPlates = 0;
if (!IrisToolbelt.isIrisWorld(world)) { int TotalNotQueuedTectonicPlates = 0;
sender().sendMessage(C.RED + "This is not an Iris world. Iris worlds: " + String.join(", ", Bukkit.getServer().getWorlds().stream().filter(IrisToolbelt::isIrisWorld).map(World::getName).toList())); int TotalTectonicPlates = 0;
return;
long lowestUnloadDuration = 0;
long highestUnloadDuration = 0;
for (World world : Bukkit.getWorlds()) {
try {
if (IrisToolbelt.access(world).getEngine() != null) {
IrisWorlds.add(world);
}
} catch (Exception e) {
// no
}
} }
for (World world : IrisWorlds) {
Engine engine = IrisToolbelt.access(world).getEngine(); Engine engine = IrisToolbelt.access(world).getEngine();
if(engine != null) { TotalQueuedTectonicPlates += (int) engine.getMantle().getToUnload();
long lastUseSize = engine.getMantle().getLastUseMapMemoryUsage(); TotalNotQueuedTectonicPlates += (int) engine.getMantle().getNotQueuedLoadedRegions();
TotalTectonicPlates += engine.getMantle().getLoadedRegionCount();
if (highestUnloadDuration <= (long) engine.getMantle().getTectonicDuration()) {
highestUnloadDuration = (long) engine.getMantle().getTectonicDuration();
}
if (lowestUnloadDuration >= (long) engine.getMantle().getTectonicDuration()) {
lowestUnloadDuration = (long) engine.getMantle().getTectonicDuration();
}
for (Chunk chunk : world.getLoadedChunks()) {
if (chunk.isLoaded()) {
TotalLoadedChunks++;
}
}
}
Iris.info("-------------------------"); Iris.info("-------------------------");
Iris.info(C.DARK_PURPLE + "Engine Status"); Iris.info(C.DARK_PURPLE + "Engine Status");
Iris.info(C.DARK_PURPLE + "Total Loaded Chunks: " + C.LIGHT_PURPLE + TotalLoadedChunks);
Iris.info(C.DARK_PURPLE + "Tectonic Limit: " + C.LIGHT_PURPLE + IrisEngineSVC.getTectonicLimit()); Iris.info(C.DARK_PURPLE + "Tectonic Limit: " + C.LIGHT_PURPLE + IrisEngineSVC.getTectonicLimit());
Iris.info(C.DARK_PURPLE + "Tectonic Loaded Plates: " + C.LIGHT_PURPLE + engine.getMantle().getLoadedRegionCount()); Iris.info(C.DARK_PURPLE + "Tectonic Total Plates: " + C.LIGHT_PURPLE + TotalTectonicPlates);
Iris.info(C.DARK_PURPLE + "Tectonic Plates: " + C.LIGHT_PURPLE + engine.getMantle().getNotClearedLoadedRegions()); Iris.info(C.DARK_PURPLE + "Tectonic Active Plates: " + C.LIGHT_PURPLE + TotalNotQueuedTectonicPlates);
Iris.info(C.DARK_PURPLE + "Tectonic ToUnload: " + C.LIGHT_PURPLE + engine.getMantle().getToUnload()); Iris.info(C.DARK_PURPLE + "Tectonic ToUnload: " + C.LIGHT_PURPLE + TotalQueuedTectonicPlates);
Iris.info(C.DARK_PURPLE + "Tectonic Unload Duration: " + C.LIGHT_PURPLE + Form.duration((long) engine.getMantle().getTectonicDuration())); Iris.info(C.DARK_PURPLE + "Lowest Tectonic Unload Duration: " + C.LIGHT_PURPLE + Form.duration(lowestUnloadDuration));
Iris.info(C.DARK_PURPLE + "Highest Tectonic Unload Duration: " + C.LIGHT_PURPLE + Form.duration(highestUnloadDuration));
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("-------------------------"); Iris.info("-------------------------");
} else { }
Iris.info(C.RED + "Engine is null!");
@Decree(description = "Test")
public void benchmarkMantle(
@Param(description = "The world to bench", aliases = {"world"})
World world
) throws IOException, ClassNotFoundException {
Engine engine = IrisToolbelt.access(world).getEngine();
int maxHeight = engine.getTarget().getHeight();
File folder = new File(Bukkit.getWorldContainer(), world.getName());
int c = 0;
//MCAUtil.read()
File tectonicplates = new File(folder, "mantle");
for (File i : Objects.requireNonNull(tectonicplates.listFiles())) {
TectonicPlate.read(maxHeight, i);
c++;
Iris.info("Loaded count: " + c );
}
}
@Decree(description = "UnloadChunks for good reasons.")
public void unloadchunks() {
List<World> IrisWorlds = new ArrayList<>();
int chunksUnloaded = 0;
for (World world : Bukkit.getWorlds()) {
try {
if (IrisToolbelt.access(world).getEngine() != null) {
IrisWorlds.add(world);
}
} catch (Exception e) {
// no
} }
} }
for (World world : IrisWorlds) {
for (Chunk chunk : world.getLoadedChunks()) {
if (chunk.isLoaded()) {
chunk.unload();
chunksUnloaded++;
}
}
}
Iris.info(C.IRIS + "Chunks Unloaded: " + chunksUnloaded);
}
@Decree(description = "Test", aliases = {"ip"})
public void network() {
try {
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
for (NetworkInterface ni : Collections.list(networkInterfaces)) {
Iris.info("Display Name: %s", ni.getDisplayName());
Enumeration<InetAddress> inetAddresses = ni.getInetAddresses();
for (InetAddress ia : Collections.list(inetAddresses)) {
Iris.info("IP: %s", ia.getHostAddress());
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Decree(description = "Test", origin = DecreeOrigin.BOTH) @Decree(description = "Test", origin = DecreeOrigin.BOTH)
public void test() { public void test() {
Iris.info("Test Developer CMD Executed"); Iris.info("Test Developer CMD Executed");

View File

@ -24,6 +24,7 @@ import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.service.StudioSVC; import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.core.tools.IrisBenchmarking; import com.volmit.iris.core.tools.IrisBenchmarking;
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.object.IrisDimension; import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.core.safeguard.UtilsSFG; import com.volmit.iris.core.safeguard.UtilsSFG;
import com.volmit.iris.engine.object.IrisWorld; import com.volmit.iris.engine.object.IrisWorld;
@ -52,6 +53,7 @@ import org.bukkit.scheduler.BukkitRunnable;
import java.io.Console; import java.io.Console;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -216,6 +218,44 @@ public class CommandIris implements DecreeExecutor {
Iris.service(StudioSVC.class).open(sender(), 1337, "overworld"); Iris.service(StudioSVC.class).open(sender(), 1337, "overworld");
} }
@Decree(description = "Check if iris has access to that specific world")
public void hasAccess(
@Param(description = "The world to access", aliases = {"world"})
World world
) {
Engine engine = IrisToolbelt.access(world).getEngine();
if (engine != null) {
sender().sendMessage("Access granted successfully.");
} else {
sender().sendMessage(C.RED + "Failed to grant access.");
}
}
@Decree(description = "All Iris Worlds on the server.", aliases = {"worlds"})
public void irisworlds() {
List<World> IrisWorlds = new ArrayList<>();
for (World world : Bukkit.getWorlds()) {
try {
if (IrisToolbelt.access(world).getEngine() != null) {
IrisWorlds.add(world);
}
} catch (Exception e) {
// no
}
}
if (sender().isPlayer()) {
sender.sendMessage(C.IRIS + "Iris Worlds:");
for (World world : IrisWorlds) {
sender.sendMessage(C.GREEN + "- " + world.getName());
}
} else {
Iris.info(C.IRIS + "Iris Worlds:");
for (World world : IrisWorlds) {
sender.sendMessage(C.GREEN + "- " + world.getName());
}
}
}
@Decree(description = "Remove an Iris world", aliases = {"del", "rm", "delete"}, sync = true) @Decree(description = "Remove an Iris world", aliases = {"del", "rm", "delete"}, sync = true)
public void remove( public void remove(
@Param(description = "The world to remove") @Param(description = "The world to remove")

View File

@ -22,7 +22,9 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.edit.BlockSignal; import com.volmit.iris.core.edit.BlockSignal;
import com.volmit.iris.core.nms.INMS; import com.volmit.iris.core.nms.INMS;
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.object.IrisBiome; import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisRegion;
import com.volmit.iris.util.data.B; import com.volmit.iris.util.data.B;
import com.volmit.iris.util.decree.DecreeExecutor; import com.volmit.iris.util.decree.DecreeExecutor;
import com.volmit.iris.util.decree.DecreeOrigin; import com.volmit.iris.util.decree.DecreeOrigin;
@ -37,6 +39,7 @@ import org.bukkit.Material;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@Decree(name = "what", origin = DecreeOrigin.PLAYER, studio = true, description = "Iris What?") @Decree(name = "what", origin = DecreeOrigin.PLAYER, studio = true, description = "Iris What?")
@ -82,6 +85,19 @@ public class CommandWhat implements DecreeExecutor {
} }
} }
@Decree(description = "What region am i in?", origin = DecreeOrigin.PLAYER)
public void region() {
try {
Chunk chunk = world().getChunkAt(player().getLocation().getBlockZ() / 16, player().getLocation().getBlockZ() / 16);
IrisRegion r = engine().getRegion(chunk);
sender().sendMessage("IRegion: " + r.getLoadKey() + " (" + r.getName() + ")");
} catch (Throwable e) {
Iris.reportError(e);
sender().sendMessage(C.IRIS + "Iris worlds only.");
}
}
@Decree(description = "What block am i looking at?", origin = DecreeOrigin.PLAYER) @Decree(description = "What block am i looking at?", origin = DecreeOrigin.PLAYER)
public void block() { public void block() {
BlockData bd; BlockData bd;
@ -147,7 +163,7 @@ public class CommandWhat implements DecreeExecutor {
sender().sendMessage("Found " + v.get() + " Nearby Markers (" + marker + ")"); sender().sendMessage("Found " + v.get() + " Nearby Markers (" + marker + ")");
} else { } else {
sender().sendMessage("Iris worlds only."); sender().sendMessage(C.IRIS + "Iris worlds only.");
} }
} }
} }

View File

@ -19,9 +19,7 @@
package com.volmit.iris.core.pregenerator; package com.volmit.iris.core.pregenerator;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.tools.IrisPackBenchmarking;
import com.volmit.iris.util.collection.KSet; import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form; import com.volmit.iris.util.format.Form;
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.math.M;
@ -30,15 +28,12 @@ import com.volmit.iris.util.math.RollingSequence;
import com.volmit.iris.util.scheduling.ChronoLatch; import com.volmit.iris.util.scheduling.ChronoLatch;
import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.Looper; import com.volmit.iris.util.scheduling.Looper;
import lombok.Getter;
import lombok.Setter;
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; import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import static com.volmit.iris.core.tools.IrisPackBenchmarking.benchmark;
public class IrisPregenerator { public class IrisPregenerator {
private final PregenTask task; private final PregenTask task;
@ -112,12 +107,8 @@ public class IrisPregenerator {
if (cl.flip()) { if (cl.flip()) {
double percentage = ((double) generated.get() / (double) totalChunks.get()) * 100; double percentage = ((double) generated.get() / (double) totalChunks.get()) * 100;
if(benchmark) {
Iris.info(C.GREEN +"Benchmark: " + C.WHITE + Form.f(generated.get()) + " of " + Form.f(totalChunks.get()) + " (%.0f%%) " + Form.f((int) chunksPerSecond.getAverage()) + "/s ETA: " + Form.duration((double) eta, 2), percentage);
} else {
Iris.info("Pregen: " + Form.f(generated.get()) + " of " + Form.f(totalChunks.get()) + " (%.0f%%) " + Form.f((int) chunksPerSecond.getAverage()) + "/s ETA: " + Form.duration(eta, 2), percentage); Iris.info("Pregen: " + Form.f(generated.get()) + " of " + Form.f(totalChunks.get()) + " (%.0f%%) " + Form.f((int) chunksPerSecond.getAverage()) + "/s ETA: " + Form.duration(eta, 2), percentage);
} }
}
return 1000; return 1000;
} }
}; };

View File

@ -4,32 +4,67 @@ import com.volmit.iris.Iris;
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;
import com.volmit.iris.engine.platform.PlatformChunkGenerator; import com.volmit.iris.engine.platform.PlatformChunkGenerator;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form; import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.mantle.TectonicPlate;
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.ChronoLatch;
import com.volmit.iris.util.scheduling.Looper; import com.volmit.iris.util.scheduling.Looper;
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.event.EventHandler;
import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.event.world.WorldUnloadEvent;
import org.checkerframework.checker.units.qual.A;
import java.util.ArrayList; import java.util.*;
import java.util.List; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Supplier; import java.util.function.Supplier;
public class IrisEngineSVC implements IrisService { public class IrisEngineSVC implements IrisService {
public static IrisEngineSVC instance;
private static final AtomicInteger tectonicLimit = new AtomicInteger(30); private static final AtomicInteger tectonicLimit = new AtomicInteger(30);
private final ReentrantLock lastUseLock = new ReentrantLock(); private final ReentrantLock lastUseLock = new ReentrantLock();
private final KMap<World, Long> lastUse = new KMap<>(); private final KMap<World, Long> lastUse = new KMap<>();
private List<World> IrisWorlds;
private Looper cacheTicker; private Looper cacheTicker;
private Looper freezeTicker;
private Looper trimTicker; private Looper trimTicker;
private Looper unloadTicker; private Looper unloadTicker;
private Looper updateTicker;
private PrecisionStopwatch trimAlive;
private PrecisionStopwatch unloadAlive;
public PrecisionStopwatch trimActiveAlive;
public PrecisionStopwatch unloadActiveAlive;
private AtomicInteger TotalTectonicPlates;
private AtomicInteger TotalQueuedTectonicPlates;
private AtomicInteger TotalNotQueuedTectonicPlates;
private AtomicBoolean IsUnloadAlive;
private AtomicBoolean IsTrimAlive;
ChronoLatch cl;
public List<World> corruptedIrisWorlds = new ArrayList<>(); public List<World> corruptedIrisWorlds = new ArrayList<>();
@Override @Override
public void onEnable() { public void onEnable() {
this.cl = new ChronoLatch(5000);
IrisWorlds = new ArrayList<>();
IsUnloadAlive = new AtomicBoolean(true);
IsTrimAlive = new AtomicBoolean(true);
trimActiveAlive = new PrecisionStopwatch();
unloadActiveAlive = new PrecisionStopwatch();
trimAlive = new PrecisionStopwatch();
unloadAlive = new PrecisionStopwatch();
TotalTectonicPlates = new AtomicInteger();
TotalQueuedTectonicPlates = new AtomicInteger();
TotalNotQueuedTectonicPlates = new AtomicInteger();
tectonicLimit.set(2); tectonicLimit.set(2);
long t = getHardware.getProcessMemory(); long t = getHardware.getProcessMemory();
while (t > 200) { while (t > 200) {
@ -37,15 +72,50 @@ public class IrisEngineSVC implements IrisService {
t = t - 200; t = t - 200;
} }
this.setup(); this.setup();
trimAlive.begin();
unloadAlive.begin();
trimActiveAlive.begin();
unloadActiveAlive.begin();
updateTicker.start();
cacheTicker.start(); cacheTicker.start();
trimTicker.start(); trimTicker.start();
unloadTicker.start(); unloadTicker.start();
freezeTicker.start();
instance = this;
} }
public static int getTectonicLimit() { public static int getTectonicLimit() {
return tectonicLimit.get(); return tectonicLimit.get();
} }
public void EngineReport() {
Iris.info(C.RED + "CRITICAL ENGINE FAILURE! The Tectonic Trim subsystem has not responded for: " + Form.duration(trimAlive.getMillis()) + ".");
}
@EventHandler
public void onWorldUnload(WorldUnloadEvent event) {
updateWorlds();
}
@EventHandler
public void onWorldLoad(WorldLoadEvent event) {
updateWorlds();
}
public void updateWorlds() {
for (World world : Bukkit.getWorlds()) {
try {
if (IrisToolbelt.access(world).getEngine() != null) {
IrisWorlds.add(world);
}
} catch (Exception e) {
// no
}
}
}
private void setup() { private void setup() {
cacheTicker = new Looper() { cacheTicker = new Looper() {
@Override @Override
@ -57,7 +127,7 @@ public class IrisEngineSVC implements IrisService {
Long last = lastUse.get(key); Long last = lastUse.get(key);
if (last == null) if (last == null)
continue; continue;
if (now - last > 60000) { // 1 minute if (now - last > 60000) {
lastUse.remove(key); lastUse.remove(key);
} }
} }
@ -67,11 +137,81 @@ public class IrisEngineSVC implements IrisService {
return 1000; return 1000;
} }
}; };
updateTicker = new Looper() {
@Override
protected long loop() {
try {
TotalQueuedTectonicPlates.set(0);
TotalNotQueuedTectonicPlates.set(0);
TotalTectonicPlates.set(0);
for (World world : IrisWorlds) {
Engine engine = IrisToolbelt.access(world).getEngine();
TotalQueuedTectonicPlates.addAndGet((int) engine.getMantle().getToUnload());
TotalNotQueuedTectonicPlates.addAndGet((int) engine.getMantle().getNotQueuedLoadedRegions());
TotalTectonicPlates.addAndGet(engine.getMantle().getLoadedRegionCount());
}
} catch (Exception e) {
return -1;
}
return 1000;
}
};
freezeTicker = new Looper() {
@Override
protected long loop() {
if (cl.flip()) {
if (!unloadTicker.isAlive()) {
Iris.debug(C.YELLOW + "UnloadTicker Found dead?");
}
if (!trimTicker.isAlive()) {
Iris.debug(C.YELLOW + "UnloadTicker Found dead?");
}
Runtime runtime = Runtime.getRuntime();
long usedMemory = runtime.totalMemory() - runtime.freeMemory();
long maxMemory = runtime.maxMemory();
double memoryUsagePercentage = ((double) usedMemory / (double) maxMemory);
double externalTrim = trimActiveAlive.getMillis();
double externalUnload = unloadActiveAlive.getMillis();
double localTrim = trimAlive.getMillis();
double localUnload = unloadAlive.getMillis();
if (localTrim > 120000) {
Iris.info(C.YELLOW + "EngineSVC Alert! The Trim subsystem has exceeded its expected response time: " + Form.duration(trimAlive.getMillis()) + ".");
}
if (localUnload > 120000) {
Iris.info(C.YELLOW + "EngineSVC Alert! The Tectonic subsystem has exceeded its expected response time: " + Form.duration(trimAlive.getMillis()) + ".");
}
if (memoryUsagePercentage > 0.9 && tectonicLimit.get() < TotalTectonicPlates.get()) {
if (localTrim > 30000 && externalTrim > 10000) {
Iris.info(C.RED + "CRITICAL EngineSVC FAILURE! The Tectonic Trim subsystem has not trimmed for: " + Form.duration(trimAlive.getMillis()) + ".");
IsTrimAlive.set(false);
} else {
Iris.info(C.IRIS + "EngineSVC reports activity within the Trim subsystem system!");
IsTrimAlive.set(true);
}
if (localUnload > 30000 && externalUnload > 12000 && TotalQueuedTectonicPlates.get() != 0) {
Iris.info(C.RED + "CRITICAL EngineSVC FAILURE! The Tectonic Unload subsystem has not unloaded for: " + Form.duration(trimAlive.getMillis()) + ".");
IsUnloadAlive.set(false);
} else {
Iris.info(C.IRIS + "EngineSVC reports activity within the Unload subsystem system!");
IsUnloadAlive.set(true);
}
}
}
return 1;
}
};
trimTicker = new Looper() { trimTicker = new Looper() {
private final Supplier<Engine> supplier = createSupplier(); private final Supplier<Engine> supplier = createSupplier();
@Override @Override
protected long loop() { protected long loop() {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
trimAlive.reset();
try { try {
Engine engine = supplier.get(); Engine engine = supplier.get();
if (engine != null) { if (engine != null) {
@ -79,7 +219,9 @@ public class IrisEngineSVC implements IrisService {
} }
} catch (Throwable e) { } catch (Throwable e) {
Iris.reportError(e); Iris.reportError(e);
// return -1; Iris.info(C.RED + "EngineSVC: Failed to trim. Please contact support!");
e.printStackTrace();
return -1;
} }
int size = lastUse.size(); int size = lastUse.size();
@ -96,6 +238,7 @@ public class IrisEngineSVC implements IrisService {
@Override @Override
protected long loop() { protected long loop() {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
unloadAlive.reset();
try { try {
Engine engine = supplier.get(); Engine engine = supplier.get();
if (engine != null) { if (engine != null) {
@ -107,6 +250,8 @@ public class IrisEngineSVC implements IrisService {
} }
} catch (Throwable e) { } catch (Throwable e) {
Iris.reportError(e); Iris.reportError(e);
Iris.info(C.RED + "EngineSVC: Failed to unload. Please contact support!");
e.printStackTrace();
return -1; return -1;
} }
@ -145,6 +290,8 @@ public class IrisEngineSVC implements IrisService {
} }
} }
} catch (Throwable e) { } catch (Throwable e) {
Iris.info(C.RED + "EngineSVC: Failed to create supplier. Please contact support!");
e.printStackTrace();
Iris.reportError(e); Iris.reportError(e);
} }
return null; return null;

View File

@ -2,30 +2,26 @@ package com.volmit.iris.core.tools;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.engine.object.*; import com.volmit.iris.engine.object.*;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form; import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.RollingSequence;
import com.volmit.iris.util.nbt.io.NBTUtil; import com.volmit.iris.util.nbt.io.NBTUtil;
import com.volmit.iris.util.nbt.io.NamedTag; import com.volmit.iris.util.nbt.io.NamedTag;
import com.volmit.iris.util.nbt.tag.*; import com.volmit.iris.util.nbt.tag.*;
import com.volmit.iris.util.plugin.VolmitPlugin;
import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.reflect.V;
import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.Looper;
import com.volmit.iris.util.scheduling.PrecisionStopwatch; import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import javassist.bytecode.ByteArray; import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.util.BlockVector; import org.bukkit.util.Vector;
import java.io.File; import java.io.File;
import java.io.FilenameFilter; import java.io.FilenameFilter;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
@ -33,15 +29,14 @@ import java.util.concurrent.atomic.AtomicInteger;
public class IrisConverter { public class IrisConverter {
public static void convertSchematics(VolmitSender sender) { public static void convertSchematics(VolmitSender sender) {
Map<Integer, BlockData> blockmap = new HashMap<>();
File folder = Iris.instance.getDataFolder("convert"); File folder = Iris.instance.getDataFolder("convert");
FilenameFilter filter = (dir, name) -> name.endsWith(".schem"); FilenameFilter filter = (dir, name) -> name.endsWith(".schem");
File[] fileList = folder.listFiles(filter); File[] fileList = folder.listFiles(filter);
for (File schem : fileList) {
try {
ExecutorService executorService = Executors.newFixedThreadPool(1); ExecutorService executorService = Executors.newFixedThreadPool(1);
executorService.submit(() -> { executorService.submit(() -> {
for (File schem : fileList) {
try {
PrecisionStopwatch p = new PrecisionStopwatch(); PrecisionStopwatch p = new PrecisionStopwatch();
boolean largeObject = false; boolean largeObject = false;
NamedTag tag = null; NamedTag tag = null;
@ -57,24 +52,26 @@ public class IrisConverter {
int objW = ((ShortTag) compound.get("Width")).getValue(); int objW = ((ShortTag) compound.get("Width")).getValue();
int objH = ((ShortTag) compound.get("Height")).getValue(); int objH = ((ShortTag) compound.get("Height")).getValue();
int objD = ((ShortTag) compound.get("Length")).getValue(); int objD = ((ShortTag) compound.get("Length")).getValue();
IrisObject object = new IrisObject(objW, objH, objD);
int mv = objW * objH * objD; int mv = objW * objH * objD;
AtomicInteger v = new AtomicInteger(0); AtomicInteger v = new AtomicInteger(0);
if (mv > 100000) { AtomicInteger fv = new AtomicInteger(0);
if (mv > 500_000) {
largeObject = true; largeObject = true;
Iris.info(C.GRAY + "Converting.. "+ schem.getName() + " -> " + schem.getName().replace(".schem", ".iob")); Iris.info(C.GRAY + "Converting.. "+ schem.getName() + " -> " + schem.getName().replace(".schem", ".iob"));
Iris.info(C.GRAY + "- It may take a while"); Iris.info(C.GRAY + "- It may take a while");
if (sender.isPlayer()) { if (sender.isPlayer()) {
J.a(() -> { J.a(() -> {
while (v.get() != mv) { // while (v.get() != mv) {
double pr = ((double) v.get() / (double ) mv); // double pr = ((double) v.get() / (double ) mv);
sender.sendProgress(pr, "Converting"); // sender.sendProgress(pr, "Converting");
J.sleep(16); // J.sleep(16);
} // }
}); });
} }
} }
CompoundTag paletteTag = (CompoundTag) compound.get("Palette"); CompoundTag paletteTag = (CompoundTag) compound.get("Palette");
Map<Integer, BlockData> blockmap = new HashMap<>(paletteTag.size(), 0.9f);
for (Map.Entry<String, Tag<?>> entry : paletteTag.getValue().entrySet()) { for (Map.Entry<String, Tag<?>> entry : paletteTag.getValue().entrySet()) {
String blockName = entry.getKey(); String blockName = entry.getKey();
BlockData bd = Bukkit.createBlockData(blockName); BlockData bd = Bukkit.createBlockData(blockName);
@ -84,18 +81,179 @@ public class IrisConverter {
} }
ByteArrayTag byteArray = (ByteArrayTag) compound.get("BlockData"); ByteArrayTag byteArray = (ByteArrayTag) compound.get("BlockData");
byte[] l = byteArray.getValue(); byte[] originalBlockArray = byteArray.getValue();
int b = 0;
int a = 0;
Map<Integer, Byte> y = new HashMap<>();
Map<Integer, Byte> x = new HashMap<>();
Map<Integer, Byte> z = new HashMap<>();
// Height adjustments
for (int h = 0; h < objH; h++) {
if (b == 0) {
y.put(h, (byte) 0);
}
if (b > 0) {
y.put(h, (byte) 1);
}
a = 0;
b = 0;
for (int d = 0; d < objD; d++) {
for (int w = 0; w < objW; w++) {
BlockData db = blockmap.get((int) originalBlockArray[fv.get()]);
if(db.getAsString().contains("minecraft:air")) {
a++;
} else {
b++;
}
fv.getAndAdd(1);
}
}
}
fv.set(0);
// Width adjustments
for (int w = 0; w < objW; w++) {
if (b == 0) {
x.put(w, (byte) 0);
}
if (b > 0) {
x.put(w, (byte) 1);
}
a = 0;
b = 0;
for (int h = 0; h < objH; h++) {
for (int d = 0; d < objD; d++) {
BlockData db = blockmap.get((int) originalBlockArray[fv.get()]);
if(db.getAsString().contains("minecraft:air")) {
a++;
} else {
b++;
}
fv.getAndAdd(1);
}
}
}
fv.set(0);
// Depth adjustments
for (int d = 0; d < objD; d++) {
if (b == 0) {
z.put(d, (byte) 0);
}
if (b > 0) {
z.put(d, (byte) 1);
}
a = 0;
b = 0;
for (int h = 0; h < objH; h++) {
for (int w = 0; w < objW; w++) {
BlockData db = blockmap.get((int) originalBlockArray[fv.get()]);
if(db.getAsString().contains("minecraft:air")) {
a++;
} else {
b++;
}
fv.getAndAdd(1);
}
}
}
fv.set(0);
int CorrectObjH = getCorrectY(y, objH);
int CorrectObjW = getCorrectX(x, objW);
int CorrectObjD = getCorrectZ(z, objD);
//IrisObject object = new IrisObject(CorrectObjW, CorrectObjH, CorrectObjH);
IrisObject object = new IrisObject(objW, objH, objD);
Vector originalVector = new Vector(objW,objH,objD);
int[] yc = null;
int[] xc = null;
int[] zc = null;
int fo = 0;
int so = 0;
int o = 0;
int c = 0;
for (Integer i : y.keySet()) {
if (y.get(i) == 0) {
o++;
}
if (y.get(i) == 1) {
c++;
if (c == 1) {
fo = o;
}
o = 0;
}
}
so = o;
yc = new int[]{fo, so};
fo = 0;
so = 0;
o = 0;
c = 0;
for (Integer i : x.keySet()) {
if (x.get(i) == 0) {
o++;
}
if (x.get(i) == 1) {
c++;
if (c == 1) {
fo = o;
}
o = 0;
}
}
so = o;
xc = new int[]{fo, so};
fo = 0;
so = 0;
o = 0;
c = 0;
for (Integer i : z.keySet()) {
if (z.get(i) == 0) {
o++;
}
if (z.get(i) == 1) {
c++;
if (c == 1) {
fo = o;
}
o = 0;
}
}
so = o;
zc = new int[]{fo, so};
int h1, h2, w1, w2, v1 = 0, volume = objW * objH * objD;
Map<Integer, Integer> blockLocationMap = new LinkedHashMap<>();
boolean hasAir = false;
int pos = 0;
for (int i : originalBlockArray) {
blockLocationMap.put(pos, i);
pos++;
}
for (int h = 0; h < objH; h++) { for (int h = 0; h < objH; h++) {
for (int d = 0; d < objD; d++) { for (int d = 0; d < objD; d++) {
for (int w = 0; w < objW; w++) { for (int w = 0; w < objW; w++) {
BlockData db = blockmap.get((int) l[v.get()]); BlockData bd = blockmap.get((int) originalBlockArray[v.get()]);
object.setUnsigned(w, h, d, db); if (!bd.getMaterial().isAir()) {
object.setUnsigned(w, h, d, bd);
}
v.getAndAdd(1); v.getAndAdd(1);
} }
} }
} }
try { try {
object.write(new File(folder, schem.getName().replace(".schem", ".iob"))); object.write(new File(folder, schem.getName().replace(".schem", ".iob")));
} catch (IOException e) { } catch (IOException e) {
@ -103,7 +261,11 @@ public class IrisConverter {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
if (sender.isPlayer()) { if (sender.isPlayer()) {
if (largeObject) {
sender.sendMessage(C.IRIS + "Converted "+ schem.getName() + " -> " + schem.getName().replace(".schem", ".iob") + " in " + Form.duration(p.getMillis()));
} else {
sender.sendMessage(C.IRIS + "Converted " + schem.getName() + " -> " + schem.getName().replace(".schem", ".iob"));
}
} }
if (largeObject) { if (largeObject) {
Iris.info(C.GRAY + "Converted "+ schem.getName() + " -> " + schem.getName().replace(".schem", ".iob") + " in " + Form.duration(p.getMillis())); Iris.info(C.GRAY + "Converted "+ schem.getName() + " -> " + schem.getName().replace(".schem", ".iob") + " in " + Form.duration(p.getMillis()));
@ -112,13 +274,120 @@ public class IrisConverter {
} }
// schem.delete(); // schem.delete();
} }
});
} catch (Exception e) { } catch (Exception e) {
Iris.info(C.RED + "Failed to convert: " + schem.getName()); Iris.info(C.RED + "Failed to convert: " + schem.getName());
if (sender.isPlayer()) {
sender.sendMessage(C.RED + "Failed to convert: " + schem.getName());
}
e.printStackTrace(); e.printStackTrace();
Iris.reportError(e); Iris.reportError(e);
} }
} }
});
}
public static boolean isNewPointFurther(int[] originalPoint, int[] oldPoint, int[] newPoint) {
int oX = oldPoint[1];
int oY = oldPoint[2];
int oZ = oldPoint[3];
int nX = newPoint[1];
int nY = newPoint[2];
int nZ = newPoint[3];
int orX = originalPoint[1];
int orY = originalPoint[2];
int orZ = originalPoint[3];
double oldDistance = Math.sqrt(Math.pow(oX - orX, 2) + Math.pow(oY - orY, 2) + Math.pow(oZ - orZ, 2));
double newDistance = Math.sqrt(Math.pow(nX - orX, 2) + Math.pow(nY - orY, 2) + Math.pow(nZ - orZ, 2));
if (newDistance > oldDistance) {
return true;
}
return false;
}
public static int[] getCoordinates(int pos, int obX, int obY, int obZ) {
int z = 0;
int[] coords = new int[4];
for (int h = 0; h < obY; h++) {
for (int d = 0; d < obZ; d++) {
for (int w = 0; w < obX; w++) {
if (z == pos) {
coords[1] = w;
coords[2] = h;
coords[3] = d;
return coords;
}
z++;
}
}
}
return null;
}
public static int getCorrectY(Map<Integer, Byte> y, int H) {
int fo = 0;
int so = 0;
int o = 0;
int c = 0;
for (Integer i : y.keySet()) {
if (y.get(i) == 0) {
o++;
}
if (y.get(i) == 1) {
c++;
if(c == 1){
fo = o;
}
o = 0;
}
}
so = o;
return H = H - (fo + so);
}
public static int getCorrectX(Map<Integer, Byte> x, int W) {
int fo = 0;
int so = 0;
int o = 0;
int c = 0;
for (Integer i : x.keySet()) {
if (x.get(i) == 0) {
o++;
}
if (x.get(i) == 1) {
c++;
if(c == 1){
fo = o;
}
o = 0;
}
}
so = o;
return W = W - (fo + so);
}
public static int getCorrectZ(Map<Integer, Byte> z, int D) {
int fo = 0;
int so = 0;
int o = 0;
int c = 0;
for (Integer i : z.keySet()) {
if (z.get(i) == 0) {
o++;
}
if (z.get(i) == 1) {
c++;
if(c == 1){
fo = o;
}
o = 0;
}
}
so = o;
return D = D - (fo + so);
} }
} }

View File

@ -46,10 +46,6 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.volmit.iris.core.tools.IrisPackBenchmarking.benchmark;
import static com.volmit.iris.core.safeguard.IrisSafeguard.unstablemode; import static com.volmit.iris.core.safeguard.IrisSafeguard.unstablemode;
/** /**
@ -86,6 +82,10 @@ public class IrisCreator {
* the world itself. Studio worlds are deleted when they are unloaded. * the world itself. Studio worlds are deleted when they are unloaded.
*/ */
private boolean studio = false; private boolean studio = false;
/**
* Benchmark mode
*/
private boolean benchmark = false;
public static boolean removeFromBukkitYml(String name) throws IOException { public static boolean removeFromBukkitYml(String name) throws IOException {
YamlConfiguration yml = YamlConfiguration.loadConfiguration(BUKKIT_YML); YamlConfiguration yml = YamlConfiguration.loadConfiguration(BUKKIT_YML);
@ -110,7 +110,7 @@ public class IrisCreator {
* @return the IrisAccess * @return the IrisAccess
* @throws IrisException shit happens * @throws IrisException shit happens
*/ */
IrisPackBenchmarking PackBench = new IrisPackBenchmarking();
public World create() throws IrisException { public World create() throws IrisException {
if (unstablemode){ if (unstablemode){
Iris.info(C.RED + "Your server is experiencing an incompatibility with the Iris plugin. Please rectify this problem to avoid further complications."); Iris.info(C.RED + "Your server is experiencing an incompatibility with the Iris plugin. Please rectify this problem to avoid further complications.");
@ -193,7 +193,7 @@ public class IrisCreator {
done.set(true); done.set(true);
if (sender.isPlayer()) { if (sender.isPlayer() && !benchmark) {
J.s(() -> { J.s(() -> {
sender.player().teleport(new Location(world.get(), 0, world.get().getHighestBlockYAt(0, 0), 0)); sender.player().teleport(new Location(world.get(), 0, world.get().getHighestBlockYAt(0, 0), 0));
}); });

View File

@ -21,97 +21,28 @@ import static com.volmit.iris.core.commands.CommandIris.BenchDimension;
public class IrisPackBenchmarking { public class IrisPackBenchmarking {
public static boolean loaded = false; public static IrisPackBenchmarking instance;
public static boolean benchmark = false; long totalChunks;
static boolean cancelled = false; long generatedChunks;
static boolean pregenInProgress = false; double elapsedTimeNs;
static long startTime;
static long totalChunks;
static long generatedChunks;
static double elapsedTimeNs;
public static void runBenchmark() { public void runBenchmark() {
// IrisPackBenchmarking IrisPackBenchmarking = new IrisPackBenchmarking();
benchmark = true;
Iris.info(C.BLUE + "Benchmarking Dimension: " + C.AQUA + BenchDimension);
//progress();
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
Iris.info(C.GOLD + "Setting everything up..");
try {
String BenchmarkFolder = "\\Benchmark";
File folder = new File(BenchmarkFolder);
if (folder.exists() && folder.isDirectory()) {
FileUtils.deleteDirectory(folder);
Iris.debug("Deleted old Benchmark");
} else {
Iris.info(C.GOLD + "Old Benchmark not found!");
if(folder.exists()){
Iris.info(C.RED + "FAILED To remove old Benchmark!");
//cancelled = true;
} }
} public void createBenchmark(){
} catch (Exception e) {
throw new RuntimeException();
}
}).thenRun(() -> {
Iris.info(C.GOLD + "Creating Benchmark Environment");
createBenchmark();
}).thenRun(() -> {
Iris.info( C.BLUE + "Benchmark Started!");
boolean done = false;
startBenchmarkTimer();
startBenchmark();
basicScheduler();
}).thenRun(() -> {
});
// cancelled = future.cancel(true);
try {
future.get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
}
private static void results(){
double averageCps = calculateAverageCPS();
Iris.info("Benchmark Dimension: " + BenchDimension);
Iris.info("Speeds");
Iris.info("- Average CPS: " + roundToTwoDecimalPlaces(averageCps));
Iris.info("Duration: " + roundToTwoDecimalPlaces(elapsedTimeNs));
}
private static void basicScheduler() {
while (true) {
totalChunks = IrisPregenerator.getLongTotalChunks();
generatedChunks = IrisPregenerator.getLongGeneratedChunks();
if(totalChunks > 0) {
if (generatedChunks >= totalChunks) {
Iris.info("Benchmark Completed!");
elapsedTimeNs = stopBenchmarkTimer();
results();
break;
}
}
//J.sleep(100); test
}
}
static void createBenchmark(){
try { try {
IrisToolbelt.createWorld() IrisToolbelt.createWorld()
.dimension(BenchDimension) .dimension(BenchDimension)
.name("Benchmark") .name("Benchmark")
.seed(1337) .seed(1337)
.studio(false) .studio(false)
.benchmark(true)
.create(); .create();
} catch (IrisException e) { } catch (IrisException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
static void startBenchmark(){ public void startBenchmark(){
int x = 0; int x = 0;
int z = 0; int z = 0;
IrisToolbelt.pregenerate(PregenTask IrisToolbelt.pregenerate(PregenTask
@ -122,49 +53,4 @@ public class IrisPackBenchmarking {
.build(), Bukkit.getWorld("Benchmark") .build(), Bukkit.getWorld("Benchmark")
); );
} }
static void startLazyBenchmark(){
int x = 0;
int z = 0;
LazyPregenerator.LazyPregenJob pregenJob = LazyPregenerator.LazyPregenJob.builder()
//.world("Benchmark")
.healingPosition(0)
.healing(false)
.chunksPerMinute(3200)
.radiusBlocks(5000)
.position(0)
.build();
LazyPregenerator pregenerator = new LazyPregenerator(pregenJob, new File("plugins/Iris/lazygen.json"));
pregenerator.start();
}
public static double calculateAverageCPS() {
double elapsedTimeSec = elapsedTimeNs / 1_000_000_000.0; // Convert to seconds
return generatedChunks / elapsedTimeSec;
}
private static void startBenchmarkTimer() {
startTime = System.nanoTime();
}
private static double stopBenchmarkTimer() {
long endTime = System.nanoTime();
return (endTime - startTime) / 1_000_000_000.0;
}
public static void deleteDirectory(File dir) {
File[] files = dir.listFiles();
if(files != null) {
for(File file: files) {
if(file.isDirectory()) {
deleteDirectory(file);
} else {
file.delete();
}
}
}
dir.delete();
}
private static double roundToTwoDecimalPlaces(double value) {
return Double.parseDouble(String.format("%.2f", value));
}
} }

View File

@ -19,8 +19,6 @@
package com.volmit.iris.engine; package com.volmit.iris.engine;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.tools.IrisPackBenchmarking;
import com.volmit.iris.engine.data.cache.AtomicCache; import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.mantle.EngineMantle; import com.volmit.iris.engine.mantle.EngineMantle;
@ -47,9 +45,6 @@ import java.io.IOException;
import java.util.Map; import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import static com.volmit.iris.core.tools.IrisPackBenchmarking.benchmark;
import static com.volmit.iris.core.safeguard.PerformanceSFG.*;
@Data @Data
@EqualsAndHashCode(exclude = "engine") @EqualsAndHashCode(exclude = "engine")
@ToString(exclude = "engine") @ToString(exclude = "engine")
@ -290,17 +285,10 @@ public class IrisEngineMantle implements EngineMantle {
x = Math.max(x, c); x = Math.max(x, c);
x = (Math.max(x, 16) + 16) >> 4; x = (Math.max(x, 16) + 16) >> 4;
x = x % 2 == 0 ? x + 1 : x; x = x % 2 == 0 ? x + 1 : x;
if (benchmark){
x = 4;
Iris.info("Mantle Size: " + x + " Chunks " + C.BLUE + "BENCHMARK MODE");
} else {
Iris.info("Mantle Size: " + x + " Chunks"); Iris.info("Mantle Size: " + x + " Chunks");
Iris.info(" Object Mantle Size: " + u + " (" + ((Math.max(u, 16) + 16) >> 4) + ")"); 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(" Jigsaw Mantle Size: " + jig + " (" + ((Math.max(jig, 16) + 16) >> 4) + ")");
Iris.info(" Carving Mantle Size: " + c + " (" + ((Math.max(c, 16) + 16) >> 4) + ")"); Iris.info(" Carving Mantle Size: " + c + " (" + ((Math.max(c, 16) + 16) >> 4) + ")");
}
return x; return x;
} }

View File

@ -298,7 +298,7 @@ public interface EngineMantle extends IObjectPlacer {
default long getToUnload(){ default long getToUnload(){
return getMantle().getToUnload().size(); return getMantle().getToUnload().size();
} }
default long getNotClearedLoadedRegions(){ default long getNotQueuedLoadedRegions(){
return getMantle().getLoadedRegions().size() - getMantle().getToUnload().size(); return getMantle().getLoadedRegions().size() - getMantle().getToUnload().size();
} }
default double getTectonicDuration(){ default double getTectonicDuration(){

View File

@ -21,6 +21,7 @@ package com.volmit.iris.util.mantle;
import com.google.common.util.concurrent.AtomicDouble; import com.google.common.util.concurrent.AtomicDouble;
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.service.IrisEngineSVC;
import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.data.cache.Cache; import com.volmit.iris.engine.data.cache.Cache;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
@ -423,7 +424,7 @@ public class Mantle {
ioTrim.set(true); ioTrim.set(true);
unloadLock.lock(); unloadLock.lock();
try { try {
if (lastUse != null) { if (lastUse != null && IrisEngineSVC.instance != null) {
if (!lastUse.isEmpty()) { if (!lastUse.isEmpty()) {
Iris.debug("Trimming Tectonic Plates older than " + Form.duration(adjustedIdleDuration.get(), 0)); Iris.debug("Trimming Tectonic Plates older than " + Form.duration(adjustedIdleDuration.get(), 0));
for (Long i : new ArrayList<>(lastUse.keySet())) { for (Long i : new ArrayList<>(lastUse.keySet())) {
@ -433,7 +434,7 @@ public class Mantle {
if (lastUseTime != null && M.ms() - lastUseTime >= finalAdjustedIdleDuration) { if (lastUseTime != null && M.ms() - lastUseTime >= finalAdjustedIdleDuration) {
toUnload.add(i); toUnload.add(i);
Iris.debug("Tectonic Region added to unload"); Iris.debug("Tectonic Region added to unload");
//Iris.panic(); IrisEngineSVC.instance.trimActiveAlive.reset();
} }
}); });
} }
@ -452,6 +453,7 @@ public class Mantle {
AtomicInteger i = new AtomicInteger(); AtomicInteger i = new AtomicInteger();
unloadLock.lock(); unloadLock.lock();
BurstExecutor burst = null; BurstExecutor burst = null;
if (IrisEngineSVC.instance != null) {
try { try {
KList<Long> copy = toUnload.copy(); KList<Long> copy = toUnload.copy();
burst = MultiBurst.burst.burst(copy.size()); burst = MultiBurst.burst.burst(copy.size());
@ -468,6 +470,7 @@ public class Mantle {
toUnload.remove(id); toUnload.remove(id);
i.incrementAndGet(); i.incrementAndGet();
Iris.debug("Unloaded Tectonic Plate " + C.DARK_GREEN + Cache.keyX(id) + " " + Cache.keyZ(id)); Iris.debug("Unloaded Tectonic Plate " + C.DARK_GREEN + Cache.keyX(id) + " " + Cache.keyZ(id));
IrisEngineSVC.instance.unloadActiveAlive.reset();
} catch (IOException e) { } catch (IOException e) {
Iris.reportError(e); Iris.reportError(e);
} }
@ -486,6 +489,8 @@ public class Mantle {
} }
return i.get(); return i.get();
} }
return i.get();
}
/** /**