mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-06-18 06:41:08 +00:00
minor headless performance improvements
This commit is contained in:
@@ -152,10 +152,12 @@ public class CommandDeveloper implements DecreeExecutor {
|
|||||||
@Param(description = "The pack to bench", aliases = {"pack"})
|
@Param(description = "The pack to bench", aliases = {"pack"})
|
||||||
IrisDimension dimension,
|
IrisDimension dimension,
|
||||||
@Param(description = "Headless", defaultValue = "false")
|
@Param(description = "Headless", defaultValue = "false")
|
||||||
boolean headless
|
boolean headless,
|
||||||
|
@Param(description = "GUI", defaultValue = "false")
|
||||||
|
boolean gui
|
||||||
) {
|
) {
|
||||||
Iris.info("test");
|
Iris.info("test");
|
||||||
IrisPackBenchmarking benchmark = new IrisPackBenchmarking(dimension, 1, headless);
|
IrisPackBenchmarking benchmark = new IrisPackBenchmarking(dimension, 1, headless, gui);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import java.io.Closeable;
|
|||||||
|
|
||||||
public interface IHeadless extends Closeable {
|
public interface IHeadless extends Closeable {
|
||||||
|
|
||||||
void saveAll();
|
void save();
|
||||||
|
|
||||||
@ChunkCoordinates
|
@ChunkCoordinates
|
||||||
boolean exists(int x, int z);
|
boolean exists(int x, int z);
|
||||||
|
|||||||
+8
-8
@@ -1,6 +1,7 @@
|
|||||||
package com.volmit.iris.core.pregenerator.methods;
|
package com.volmit.iris.core.pregenerator.methods;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.core.IrisSettings;
|
||||||
import com.volmit.iris.core.nms.IHeadless;
|
import com.volmit.iris.core.nms.IHeadless;
|
||||||
import com.volmit.iris.core.nms.INMS;
|
import com.volmit.iris.core.nms.INMS;
|
||||||
import com.volmit.iris.core.pregenerator.PregenListener;
|
import com.volmit.iris.core.pregenerator.PregenListener;
|
||||||
@@ -15,14 +16,14 @@ import java.util.concurrent.Semaphore;
|
|||||||
public class HeadlessPregenMethod implements PregeneratorMethod {
|
public class HeadlessPregenMethod implements PregeneratorMethod {
|
||||||
private final Engine engine;
|
private final Engine engine;
|
||||||
private final IHeadless headless;
|
private final IHeadless headless;
|
||||||
private final MultiBurst burst;
|
|
||||||
private final Semaphore semaphore;
|
private final Semaphore semaphore;
|
||||||
|
private final int max;
|
||||||
|
|
||||||
public HeadlessPregenMethod(Engine engine) {
|
public HeadlessPregenMethod(Engine engine) {
|
||||||
|
this.max = IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getParallelism());
|
||||||
this.engine = engine;
|
this.engine = engine;
|
||||||
this.headless = INMS.get().createHeadless(engine);
|
this.headless = INMS.get().createHeadless(engine);
|
||||||
this.burst = new MultiBurst("Iris Headless", Thread.MAX_PRIORITY);
|
this.semaphore = new Semaphore(max);
|
||||||
this.semaphore = new Semaphore(1024);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -31,10 +32,9 @@ public class HeadlessPregenMethod implements PregeneratorMethod {
|
|||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
try {
|
try {
|
||||||
semaphore.acquire(1024);
|
semaphore.acquire(max);
|
||||||
} catch (InterruptedException ignored) {}
|
} catch (InterruptedException ignored) {}
|
||||||
burst.close();
|
headless.save();
|
||||||
headless.saveAll();
|
|
||||||
try {
|
try {
|
||||||
headless.close();
|
headless.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -45,7 +45,7 @@ public class HeadlessPregenMethod implements PregeneratorMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save() {
|
public void save() {
|
||||||
headless.saveAll();
|
headless.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -69,7 +69,7 @@ public class HeadlessPregenMethod implements PregeneratorMethod {
|
|||||||
semaphore.release();
|
semaphore.release();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
burst.complete(() -> {
|
MultiBurst.burst.complete(() -> {
|
||||||
try {
|
try {
|
||||||
listener.onChunkGenerating(x, z);
|
listener.onChunkGenerating(x, z);
|
||||||
headless.generateChunk(x, z);
|
headless.generateChunk(x, z);
|
||||||
|
|||||||
@@ -45,15 +45,17 @@ public class IrisPackBenchmarking {
|
|||||||
private IrisDimension IrisDimension;
|
private IrisDimension IrisDimension;
|
||||||
private int radius;
|
private int radius;
|
||||||
private final boolean headless;
|
private final boolean headless;
|
||||||
|
private final boolean gui;
|
||||||
private boolean finished = false;
|
private boolean finished = false;
|
||||||
private Engine engine;
|
private Engine engine;
|
||||||
PrecisionStopwatch stopwatch;
|
PrecisionStopwatch stopwatch;
|
||||||
|
|
||||||
public IrisPackBenchmarking(IrisDimension dimension, int r, boolean headless) {
|
public IrisPackBenchmarking(IrisDimension dimension, int r, boolean headless, boolean gui) {
|
||||||
instance = this;
|
instance = this;
|
||||||
this.IrisDimension = dimension;
|
this.IrisDimension = dimension;
|
||||||
this.radius = r;
|
this.radius = r;
|
||||||
this.headless = headless;
|
this.headless = headless;
|
||||||
|
this.gui = gui;
|
||||||
runBenchmark();
|
runBenchmark();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +171,7 @@ public class IrisPackBenchmarking {
|
|||||||
int z = 0;
|
int z = 0;
|
||||||
IrisToolbelt.pregenerate(PregenTask
|
IrisToolbelt.pregenerate(PregenTask
|
||||||
.builder()
|
.builder()
|
||||||
.gui(false)
|
.gui(gui)
|
||||||
.center(new Position2(x, z))
|
.center(new Position2(x, z))
|
||||||
.width(5)
|
.width(5)
|
||||||
.height(5)
|
.height(5)
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class Headless implements IHeadless, LevelHeightAccessor {
|
|||||||
private final Engine engine;
|
private final Engine engine;
|
||||||
private final RegionFileStorage storage;
|
private final RegionFileStorage storage;
|
||||||
private final Queue<ProtoChunk> chunkQueue = new ArrayDeque<>();
|
private final Queue<ProtoChunk> chunkQueue = new ArrayDeque<>();
|
||||||
private final ReentrantLock manualLock = new ReentrantLock();
|
private final ReentrantLock saveLock = new ReentrantLock();
|
||||||
private final KMap<String, Holder<Biome>> customBiomes = new KMap<>();
|
private final KMap<String, Holder<Biome>> customBiomes = new KMap<>();
|
||||||
private final KMap<NamespacedKey, Holder<Biome>> minecraftBiomes = new KMap<>();
|
private final KMap<NamespacedKey, Holder<Biome>> minecraftBiomes = new KMap<>();
|
||||||
private boolean closed = false;
|
private boolean closed = false;
|
||||||
@@ -60,11 +60,7 @@ public class Headless implements IHeadless, LevelHeightAccessor {
|
|||||||
var queueLooper = new Looper() {
|
var queueLooper = new Looper() {
|
||||||
@Override
|
@Override
|
||||||
protected long loop() {
|
protected long loop() {
|
||||||
if (manualLock.isLocked()) {
|
save();
|
||||||
manualLock.lock();
|
|
||||||
manualLock.unlock();
|
|
||||||
}
|
|
||||||
saveAll();
|
|
||||||
return closed ? -1 : 100;
|
return closed ? -1 : 100;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -84,17 +80,10 @@ public class Headless implements IHeadless, LevelHeightAccessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveAll() {
|
public void save() {
|
||||||
manualLock.lock();
|
|
||||||
try {
|
|
||||||
save();
|
|
||||||
} finally {
|
|
||||||
manualLock.unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void save() {
|
|
||||||
if (closed) return;
|
if (closed) return;
|
||||||
|
saveLock.lock();
|
||||||
|
try {
|
||||||
while (!chunkQueue.isEmpty()) {
|
while (!chunkQueue.isEmpty()) {
|
||||||
ChunkAccess chunk = chunkQueue.poll();
|
ChunkAccess chunk = chunkQueue.poll();
|
||||||
if (chunk == null) break;
|
if (chunk == null) break;
|
||||||
@@ -105,6 +94,9 @@ public class Headless implements IHeadless, LevelHeightAccessor {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
saveLock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user