mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
Performance Improvements
This commit is contained in:
parent
4cd3f9bd38
commit
487dab793a
@ -133,7 +133,7 @@ public class Pregenerator implements Listener {
|
||||
this.directWriter = new DirectWorldWriter(world.getWorldFolder());
|
||||
this.running = new AtomicBoolean(true);
|
||||
this.active = new AtomicBoolean(true);
|
||||
MultiBurst burst = new MultiBurst(Runtime.getRuntime().availableProcessors());
|
||||
MultiBurst burst = new MultiBurst("Iris Pregenerator", 9, Runtime.getRuntime().availableProcessors() + 4);
|
||||
int mcaSize = (((blockSize >> 4) + 2) >> 5) + 1;
|
||||
onComplete = new KList<>();
|
||||
max = new ChunkPosition(0, 0);
|
||||
|
@ -25,6 +25,9 @@ import com.volmit.iris.engine.object.IrisBiome;
|
||||
import com.volmit.iris.engine.object.IrisBiomePaletteLayer;
|
||||
import com.volmit.iris.engine.object.IrisDecorator;
|
||||
import com.volmit.iris.engine.object.IrisObjectPlacement;
|
||||
import com.volmit.iris.engine.parallel.MultiBurst;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||
@ -38,6 +41,8 @@ import org.bukkit.generator.BlockPopulator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public class IrisEngine extends BlockPopulator implements Engine {
|
||||
@Getter
|
||||
@ -159,7 +164,6 @@ public class IrisEngine extends BlockPopulator implements Engine {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
Hunk<BlockData> blocks = vblocks;
|
||||
|
||||
|
||||
switch (getDimension().getTerrainMode()) {
|
||||
case NORMAL -> {
|
||||
getFramework().getEngineParallax().generateParallaxArea(x >> 4, z >> 4);
|
||||
|
@ -54,7 +54,6 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
|
||||
IrisBiome biome;
|
||||
KList<BlockData> blocks, fblocks;
|
||||
|
||||
|
||||
for (int xf = 0; xf < h.getWidth(); xf++) {
|
||||
for (zf = 0; zf < h.getDepth(); zf++) {
|
||||
realX = (int) modX(xf + x);
|
||||
|
@ -42,7 +42,6 @@ public class EngineTarget {
|
||||
this.height = height;
|
||||
this.dimension = dimension;
|
||||
this.data = data;
|
||||
// TODO: WARNING HEIGHT
|
||||
this.parallaxWorld = new ParallaxWorld(256, new File(world.getWorldFolder(), "iris/" + dimension.getLoadKey() + "/parallax"));
|
||||
this.inverted = inverted;
|
||||
this.burster = new MultiBurst(threads);
|
||||
|
@ -44,6 +44,14 @@ public abstract class PaletteHunkIOAdapter<T> implements HunkIOAdapter<T> {
|
||||
}
|
||||
});
|
||||
|
||||
for (int i = 0; i < t.getWidth(); i++) {
|
||||
for (int j = 0; j < t.getHeight(); j++) {
|
||||
for (int k = 0; k < t.getDepth(); k++) {
|
||||
T w = t.get(i, j, k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
palette.write(this, dos);
|
||||
dos.writeInt(nonNull.get() + Integer.MIN_VALUE);
|
||||
AtomicBoolean failure = new AtomicBoolean(false);
|
||||
|
@ -25,10 +25,13 @@ import com.volmit.iris.engine.hunk.io.HunkRegion;
|
||||
import com.volmit.iris.engine.hunk.io.HunkRegionSlice;
|
||||
import com.volmit.iris.engine.object.tile.TileData;
|
||||
import com.volmit.iris.engine.parallel.GridLock;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
import com.volmit.iris.util.math.M;
|
||||
import com.volmit.iris.util.oldnbt.ByteArrayTag;
|
||||
import com.volmit.iris.util.oldnbt.CompoundTag;
|
||||
import com.volmit.iris.util.oldnbt.Tag;
|
||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||
import org.bukkit.block.TileState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
@ -153,6 +156,7 @@ public class ParallaxRegion extends HunkRegion {
|
||||
}
|
||||
|
||||
public synchronized void save() throws IOException {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
blockSlice.save();
|
||||
objectSlice.save();
|
||||
entitySlice.save();
|
||||
@ -160,6 +164,7 @@ public class ParallaxRegion extends HunkRegion {
|
||||
updateSlice.save();
|
||||
saveMetaHunk();
|
||||
super.save();
|
||||
Iris.debug("Saved Parallax Region " + C.AQUA + getX() + "," + getZ() + C.LIGHT_PURPLE + " in " + C.RED + Form.duration(p.getMilliseconds(), 0));
|
||||
}
|
||||
|
||||
public int unload() {
|
||||
|
@ -22,8 +22,10 @@ import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.engine.hunk.Hunk;
|
||||
import com.volmit.iris.engine.object.tile.TileData;
|
||||
import com.volmit.iris.engine.parallel.MultiBurst;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import org.bukkit.block.TileState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
@ -232,11 +234,12 @@ public class ParallaxWorld implements ParallaxAccess {
|
||||
|
||||
@Override
|
||||
public void saveAll() {
|
||||
J.a(this::saveAllNOW);
|
||||
MultiBurst.burst.lazy(this::saveAllNOW);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveAllNOW() {
|
||||
Iris.debug("Saving " + C.GREEN + loadedRegions.size() + " Parallax Regions");
|
||||
for (ParallaxRegion i : loadedRegions.v()) {
|
||||
if (save.contains(key(i.getX(), i.getZ()))) {
|
||||
save(i.getX(), i.getZ());
|
||||
|
@ -21,18 +21,17 @@ package com.volmit.iris.engine.parallel;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
public class MultiBurst {
|
||||
public static final MultiBurst burst = new MultiBurst("Iris Burster", 10, Runtime.getRuntime().availableProcessors());
|
||||
public static final MultiBurst burst = new MultiBurst("Iris", 6, Runtime.getRuntime().availableProcessors());
|
||||
private final ExecutorService service;
|
||||
private ExecutorService syncService;
|
||||
private int tid;
|
||||
|
||||
|
||||
public MultiBurst(int tc) {
|
||||
this("Iris Generator", 6, tc);
|
||||
this("Iris", 6, tc);
|
||||
}
|
||||
|
||||
public MultiBurst(String name, int priority, int tc) {
|
||||
@ -73,10 +72,22 @@ public class MultiBurst {
|
||||
return burst(16);
|
||||
}
|
||||
|
||||
public <T> Future<T> lazySubmit(Callable<T> o) {
|
||||
return service.submit(o);
|
||||
}
|
||||
|
||||
public void lazy(Runnable o) {
|
||||
service.execute(o);
|
||||
}
|
||||
|
||||
public Future<?> future(Runnable o) {
|
||||
return service.submit(o);
|
||||
}
|
||||
|
||||
public CompletableFuture<?> complete(Runnable o) {
|
||||
return CompletableFuture.runAsync(o, service);
|
||||
}
|
||||
|
||||
public void shutdownNow() {
|
||||
service.shutdownNow().forEach(Runnable::run);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
package com.volmit.iris.util.scheduling;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.engine.parallel.MultiBurst;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.function.NastyFunction;
|
||||
import com.volmit.iris.util.function.NastyFuture;
|
||||
@ -34,22 +35,6 @@ import java.util.function.Supplier;
|
||||
@SuppressWarnings("ALL")
|
||||
public class J {
|
||||
private static int tid = 0;
|
||||
private static final ExecutorService e = Executors.newCachedThreadPool(new ThreadFactory() {
|
||||
@Override
|
||||
public Thread newThread(Runnable r) {
|
||||
tid++;
|
||||
Thread t = new Thread(r);
|
||||
t.setName("Iris Actuator " + tid);
|
||||
t.setPriority(8);
|
||||
t.setUncaughtExceptionHandler((et, e) ->
|
||||
{
|
||||
Iris.info("Exception encountered in " + et.getName());
|
||||
e.printStackTrace();
|
||||
});
|
||||
|
||||
return t;
|
||||
}
|
||||
});
|
||||
|
||||
public static void dofor(int a, Function<Integer, Boolean> c, int ch, Consumer<Integer> d) {
|
||||
for (int i = a; c.apply(i); i += ch) {
|
||||
@ -73,7 +58,7 @@ public class J {
|
||||
}
|
||||
|
||||
public static void arun(Runnable a) {
|
||||
e.submit(() -> {
|
||||
MultiBurst.burst.lazy(() -> {
|
||||
try {
|
||||
a.run();
|
||||
} catch (Throwable e) {
|
||||
@ -85,7 +70,7 @@ public class J {
|
||||
}
|
||||
|
||||
public static void a(Runnable a) {
|
||||
e.submit(() -> {
|
||||
MultiBurst.burst.lazy(() -> {
|
||||
try {
|
||||
a.run();
|
||||
} catch (Throwable e) {
|
||||
@ -97,7 +82,7 @@ public class J {
|
||||
}
|
||||
|
||||
public static <T> Future<T> a(Callable<T> a) {
|
||||
return e.submit(a);
|
||||
return MultiBurst.burst.lazySubmit(a);
|
||||
}
|
||||
|
||||
public static void attemptAsync(NastyRunnable r) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user