minor headless performance improvements

This commit is contained in:
CrazyDev22
2024-05-18 23:34:53 +02:00
parent 9bf7fdf174
commit 65aa9dc343
5 changed files with 33 additions and 37 deletions

View File

@@ -152,10 +152,12 @@ public class CommandDeveloper implements DecreeExecutor {
@Param(description = "The pack to bench", aliases = {"pack"})
IrisDimension dimension,
@Param(description = "Headless", defaultValue = "false")
boolean headless
boolean headless,
@Param(description = "GUI", defaultValue = "false")
boolean gui
) {
Iris.info("test");
IrisPackBenchmarking benchmark = new IrisPackBenchmarking(dimension, 1, headless);
IrisPackBenchmarking benchmark = new IrisPackBenchmarking(dimension, 1, headless, gui);
}

View File

@@ -9,7 +9,7 @@ import java.io.Closeable;
public interface IHeadless extends Closeable {
void saveAll();
void save();
@ChunkCoordinates
boolean exists(int x, int z);

View File

@@ -1,6 +1,7 @@
package com.volmit.iris.core.pregenerator.methods;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.nms.IHeadless;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.core.pregenerator.PregenListener;
@@ -15,14 +16,14 @@ import java.util.concurrent.Semaphore;
public class HeadlessPregenMethod implements PregeneratorMethod {
private final Engine engine;
private final IHeadless headless;
private final MultiBurst burst;
private final Semaphore semaphore;
private final int max;
public HeadlessPregenMethod(Engine engine) {
this.max = IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getParallelism());
this.engine = engine;
this.headless = INMS.get().createHeadless(engine);
this.burst = new MultiBurst("Iris Headless", Thread.MAX_PRIORITY);
this.semaphore = new Semaphore(1024);
this.semaphore = new Semaphore(max);
}
@Override
@@ -31,10 +32,9 @@ public class HeadlessPregenMethod implements PregeneratorMethod {
@Override
public void close() {
try {
semaphore.acquire(1024);
semaphore.acquire(max);
} catch (InterruptedException ignored) {}
burst.close();
headless.saveAll();
headless.save();
try {
headless.close();
} catch (IOException e) {
@@ -45,7 +45,7 @@ public class HeadlessPregenMethod implements PregeneratorMethod {
@Override
public void save() {
headless.saveAll();
headless.save();
}
@Override
@@ -69,7 +69,7 @@ public class HeadlessPregenMethod implements PregeneratorMethod {
semaphore.release();
return;
}
burst.complete(() -> {
MultiBurst.burst.complete(() -> {
try {
listener.onChunkGenerating(x, z);
headless.generateChunk(x, z);

View File

@@ -45,15 +45,17 @@ public class IrisPackBenchmarking {
private IrisDimension IrisDimension;
private int radius;
private final boolean headless;
private final boolean gui;
private boolean finished = false;
private Engine engine;
PrecisionStopwatch stopwatch;
public IrisPackBenchmarking(IrisDimension dimension, int r, boolean headless) {
public IrisPackBenchmarking(IrisDimension dimension, int r, boolean headless, boolean gui) {
instance = this;
this.IrisDimension = dimension;
this.radius = r;
this.headless = headless;
this.gui = gui;
runBenchmark();
}
@@ -169,7 +171,7 @@ public class IrisPackBenchmarking {
int z = 0;
IrisToolbelt.pregenerate(PregenTask
.builder()
.gui(false)
.gui(gui)
.center(new Position2(x, z))
.width(5)
.height(5)