mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
Thread counts synced
This commit is contained in:
parent
f4b41a43cf
commit
326bddad2a
@ -155,30 +155,6 @@ public class Iris extends VolmitPlugin implements Listener {
|
||||
Iris.info("Data Packs Setup!");
|
||||
}
|
||||
|
||||
public static int getThreadCount() {
|
||||
int tc = IrisSettings.get().getConcurrency().getThreadCount();
|
||||
|
||||
if (tc <= 0) {
|
||||
int p = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
return p > 16 ? 16 : Math.max(p, 4);
|
||||
}
|
||||
|
||||
return tc;
|
||||
}
|
||||
|
||||
private static boolean doesSupport3DBiomes() {
|
||||
try {
|
||||
int v = Integer.parseInt(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]);
|
||||
|
||||
return v >= 15;
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean doesSupportCustomModels() {
|
||||
try {
|
||||
int v = Integer.parseInt(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]);
|
||||
|
@ -56,14 +56,25 @@ public class IrisSettings {
|
||||
return getParallax().getParallaxRegionEvictionMS();
|
||||
}
|
||||
|
||||
public static int getThreadCount(int c)
|
||||
{
|
||||
if(c < 2 && c >= 0)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
return c < 0 ? Runtime.getRuntime().availableProcessors() / -c : c;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IrisSettingsCache {
|
||||
public int streamingCacheSize = 8192;
|
||||
public int complexCacheSize = 131072;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IrisSettingsConcurrency {
|
||||
public int threadCount = -1;
|
||||
public int pregenThreadCount = -1;
|
||||
}
|
||||
|
||||
@Data
|
||||
@ -100,7 +111,6 @@ public class IrisSettings {
|
||||
public boolean systemEntitySpawnOverrides = true;
|
||||
public boolean systemEntityInitialSpawns = true;
|
||||
public int maxBiomeChildDepth = 5;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package com.volmit.iris.core.pregenerator;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KSet;
|
||||
import com.volmit.iris.util.math.M;
|
||||
@ -96,6 +97,7 @@ public class IrisPregenerator {
|
||||
generated.get(), totalChunks.get(),
|
||||
totalChunks.get() - generated.get(),
|
||||
eta, M.ms() - startTime.get(), currentGeneratorMethod.get());
|
||||
|
||||
return 1000;
|
||||
}
|
||||
};
|
||||
|
@ -23,12 +23,12 @@ import com.volmit.iris.core.pregenerator.PregeneratorMethod;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class PaperOrMedievalPregenMethod implements PregeneratorMethod {
|
||||
public class AsyncOrMedievalPregenMethod implements PregeneratorMethod {
|
||||
private final PregeneratorMethod method;
|
||||
|
||||
public PaperOrMedievalPregenMethod(World world, int threads)
|
||||
public AsyncOrMedievalPregenMethod(World world, int threads)
|
||||
{
|
||||
method = PaperLib.isPaper() ? new PaperAsyncPregenMethod(world, threads) : new MedievalPregenMethod(world);
|
||||
method = PaperLib.isPaper() ? new AsyncPregenMethod(world, threads) : new MedievalPregenMethod(world);
|
||||
}
|
||||
|
||||
@Override
|
@ -18,6 +18,7 @@
|
||||
|
||||
package com.volmit.iris.core.pregenerator.methods;
|
||||
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.core.pregenerator.PregenListener;
|
||||
import com.volmit.iris.core.pregenerator.PregeneratorMethod;
|
||||
import com.volmit.iris.engine.parallel.MultiBurst;
|
||||
@ -30,12 +31,12 @@ import org.bukkit.World;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public class PaperAsyncPregenMethod implements PregeneratorMethod {
|
||||
public class AsyncPregenMethod implements PregeneratorMethod {
|
||||
private final World world;
|
||||
private final MultiBurst burst;
|
||||
private final KList<CompletableFuture<?>> future;
|
||||
|
||||
public PaperAsyncPregenMethod(World world, int threads)
|
||||
public AsyncPregenMethod(World world, int threads)
|
||||
{
|
||||
if(!PaperLib.isPaper())
|
||||
{
|
||||
@ -119,7 +120,7 @@ public class PaperAsyncPregenMethod implements PregeneratorMethod {
|
||||
|
||||
@Override
|
||||
public void generateChunk(int x, int z, PregenListener listener) {
|
||||
if(future.size() > 16)
|
||||
if(future.size() > IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getPregenThreadCount()))
|
||||
{
|
||||
waitForChunks();
|
||||
}
|
@ -38,7 +38,7 @@ public class HybridPregenMethod implements PregeneratorMethod {
|
||||
this.world = world;
|
||||
headless = supportsHeadless(world)
|
||||
? new HeadlessPregenMethod(HeadlessWorld.from(world)) : new DummyPregenMethod();
|
||||
inWorld = new PaperOrMedievalPregenMethod(world, threads);
|
||||
inWorld = new AsyncOrMedievalPregenMethod(world, threads);
|
||||
}
|
||||
|
||||
private boolean supportsHeadless(World world) {
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package com.volmit.iris.core.pregenerator.methods;
|
||||
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.core.pregenerator.PregenListener;
|
||||
import com.volmit.iris.core.pregenerator.PregeneratorMethod;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
@ -98,7 +99,7 @@ public class MedievalPregenMethod implements PregeneratorMethod {
|
||||
|
||||
@Override
|
||||
public void generateChunk(int x, int z, PregenListener listener) {
|
||||
if(futures.size() > 32)
|
||||
if(futures.size() > IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getPregenThreadCount()))
|
||||
{
|
||||
waitForChunks();
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ public class IrisComplex implements DataProvider {
|
||||
}
|
||||
|
||||
public IrisComplex(Engine engine, boolean simple) {
|
||||
int cacheSize = 1024 * 128;
|
||||
int cacheSize = 131072;
|
||||
IrisBiome emptyBiome = new IrisBiome();
|
||||
this.rng = new RNG(engine.getWorld().seed());
|
||||
this.data = engine.getData();
|
||||
|
@ -25,10 +25,7 @@ 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.documentation.ChunkCoordinates;
|
||||
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;
|
||||
@ -42,8 +39,6 @@ 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
|
||||
|
@ -302,7 +302,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
||||
initialized.set(true);
|
||||
IrisDimension dim = getDimension(world);
|
||||
IrisDataManager data = production ? new IrisDataManager(getDataFolder(world)) : dim.getLoader().copy();
|
||||
compound.set(new IrisEngineCompound(world, dim, data, Iris.getThreadCount()));
|
||||
compound.set(new IrisEngineCompound(world, dim, data, IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getThreadCount())));
|
||||
compound.get().setStudio(!production);
|
||||
populators.clear();
|
||||
populators.addAll(compound.get().getPopulators());
|
||||
|
@ -272,7 +272,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
||||
int i, j;
|
||||
KList<Runnable> after = new KList<>();
|
||||
int bs = (int) Math.pow((s * 2) + 1, 2);
|
||||
BurstExecutor burst = MultiBurst.burst.burst(bs);
|
||||
BurstExecutor burst = getEngine().getTarget().getBurster().burst(bs);
|
||||
for (i = -s; i <= s; i++) {
|
||||
for (j = -s; j <= s; j++) {
|
||||
int xx = i + x;
|
||||
@ -294,7 +294,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
||||
burst.complete();
|
||||
|
||||
if (getEngine().getDimension().isPlaceObjects()) {
|
||||
burst = MultiBurst.burst.burst(bs);
|
||||
burst = getEngine().getTarget().getBurster().burst(bs);
|
||||
|
||||
for (i = -s; i <= s; i++) {
|
||||
int ii = i;
|
||||
@ -310,7 +310,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
||||
}
|
||||
|
||||
burst.complete();
|
||||
burst = MultiBurst.burst.burst(bs);
|
||||
burst = getEngine().getTarget().getBurster().burst(bs);
|
||||
|
||||
for (i = -s; i <= s; i++) {
|
||||
int ii = i;
|
||||
@ -323,7 +323,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
||||
burst.complete();
|
||||
}
|
||||
|
||||
MultiBurst.burst.burst(after);
|
||||
getEngine().getTarget().getBurster().burst(after);
|
||||
getParallaxAccess().setChunkGenerated(x, z);
|
||||
p.end();
|
||||
getEngine().getMetrics().getParallax().put(p.getMilliseconds());
|
||||
@ -677,7 +677,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
||||
}
|
||||
|
||||
Iris.verbose("Checking sizes for " + Form.f(objects.size()) + " referenced objects.");
|
||||
BurstExecutor e = MultiBurst.burst.burst(objects.size());
|
||||
BurstExecutor e = getEngine().getTarget().getBurster().burst(objects.size());
|
||||
KMap<String, BlockVector> sizeCache = new KMap<>();
|
||||
for (String i : objects) {
|
||||
e.queue(() -> {
|
||||
|
@ -42,9 +42,9 @@ public class EngineTarget {
|
||||
this.height = height;
|
||||
this.dimension = dimension;
|
||||
this.data = data;
|
||||
this.parallaxWorld = new ParallaxWorld(256, new File(world.worldFolder(), "iris/" + dimension.getLoadKey() + "/parallax"));
|
||||
this.inverted = inverted;
|
||||
this.burster = new MultiBurst(threads);
|
||||
this.burster = new MultiBurst("Iris Engine " + dimension.getName(), threads, 6);
|
||||
this.parallaxWorld = new ParallaxWorld(burster, 256, new File(world.worldFolder(), "iris/" + dimension.getLoadKey() + "/parallax"));
|
||||
}
|
||||
|
||||
public EngineTarget(IrisWorld world, IrisDimension dimension, IrisDataManager data, int height, int threads) {
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package com.volmit.iris.engine.headless;
|
||||
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.core.pregenerator.PregenListener;
|
||||
import com.volmit.iris.engine.data.mca.LoadFlags;
|
||||
import com.volmit.iris.engine.data.mca.MCAFile;
|
||||
@ -43,7 +44,7 @@ public class HeadlessGenerator {
|
||||
public HeadlessGenerator(HeadlessWorld world)
|
||||
{
|
||||
this.world = world;
|
||||
burst = new MultiBurst("Iris Headless Generator", 9, Runtime.getRuntime().availableProcessors());
|
||||
burst = new MultiBurst("Iris Headless Generator", 9, IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getPregenThreadCount()));
|
||||
writer = new NBTWorld(world.getWorld().worldFolder());
|
||||
generator = new EngineCompositeGenerator(world.getDimension().getLoadKey(), !world.isStudio());
|
||||
generator.assignHeadlessGenerator(this);
|
||||
|
@ -98,8 +98,8 @@ public class HunkRegionSlice<T> {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void save() {
|
||||
BurstExecutor e = MultiBurst.burst.burst();
|
||||
public synchronized void save(MultiBurst burst) {
|
||||
BurstExecutor e = burst.burst();
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -25,6 +25,7 @@ import com.bergerkiller.bukkit.common.utils.MathUtil;
|
||||
import com.bergerkiller.bukkit.common.utils.WorldUtil;
|
||||
import com.bergerkiller.bukkit.common.wrappers.LongHashSet;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
|
||||
@ -261,7 +262,7 @@ public class LightingTaskBatch implements LightingTask {
|
||||
LightingChunk nextChunk = null;
|
||||
CompletableFuture<Void> nextChunkFuture = null;
|
||||
synchronized (chunks_lock) {
|
||||
for (; i < chunks.length && numBeingLoaded < Iris.getThreadCount(); i++) {
|
||||
for (; i < chunks.length && numBeingLoaded < IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getThreadCount()); i++) {
|
||||
LightingChunk lc = chunks[i];
|
||||
if (lc.loadingStarted) {
|
||||
continue; // Already (being) loaded
|
||||
|
@ -25,6 +25,7 @@ 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.engine.parallel.MultiBurst;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
import com.volmit.iris.util.math.M;
|
||||
@ -50,16 +51,19 @@ public class ParallaxRegion extends HunkRegion {
|
||||
private final GridLock lock;
|
||||
private long lastUse;
|
||||
private final int height;
|
||||
private final MultiBurst burst;
|
||||
|
||||
public ParallaxRegion(int height, File folder, int x, int z, CompoundTag compound) {
|
||||
public ParallaxRegion(MultiBurst burst, int height, File folder, int x, int z, CompoundTag compound) {
|
||||
super(folder, x, z, compound);
|
||||
this.burst = burst;
|
||||
this.height = height;
|
||||
setupSlices();
|
||||
lock = new GridLock(32, 32);
|
||||
}
|
||||
|
||||
public ParallaxRegion(int height, File folder, int x, int z) {
|
||||
public ParallaxRegion(MultiBurst burst, int height, File folder, int x, int z) {
|
||||
super(folder, x, z);
|
||||
this.burst = burst;
|
||||
this.height = height;
|
||||
setupSlices();
|
||||
lock = new GridLock(32, 32);
|
||||
@ -155,12 +159,13 @@ public class ParallaxRegion extends HunkRegion {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void save() throws IOException {
|
||||
blockSlice.save();
|
||||
objectSlice.save();
|
||||
entitySlice.save();
|
||||
tileSlice.save();
|
||||
updateSlice.save();
|
||||
blockSlice.save(burst);
|
||||
objectSlice.save(burst);
|
||||
entitySlice.save(burst);
|
||||
tileSlice.save(burst);
|
||||
updateSlice.save(burst);
|
||||
saveMetaHunk();
|
||||
Iris.debug("Saved Parallax Region "+ C.GOLD + getX() + " " + getZ());
|
||||
super.save();
|
||||
|
@ -40,10 +40,12 @@ public class ParallaxWorld implements ParallaxAccess {
|
||||
private final KMap<Long, ParallaxRegion> loadedRegions;
|
||||
private final KList<Long> save;
|
||||
private final File folder;
|
||||
private final MultiBurst burst;
|
||||
private final int height;
|
||||
|
||||
public ParallaxWorld(int height, File folder) {
|
||||
public ParallaxWorld(MultiBurst burst, int height, File folder) {
|
||||
this.height = height;
|
||||
this.burst = burst;
|
||||
this.folder = folder;
|
||||
save = new KList<>();
|
||||
loadedRegions = new KMap<>();
|
||||
@ -125,7 +127,7 @@ public class ParallaxWorld implements ParallaxAccess {
|
||||
return loadedRegions.get(key(x, z));
|
||||
}
|
||||
|
||||
ParallaxRegion v = new ParallaxRegion(height, folder, x, z);
|
||||
ParallaxRegion v = new ParallaxRegion(burst, height, folder, x, z);
|
||||
loadedRegions.put(key(x, z), v);
|
||||
|
||||
return v;
|
||||
|
Loading…
x
Reference in New Issue
Block a user