mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
Fix
This commit is contained in:
parent
9c376183e0
commit
9896d6e6b2
@ -30,6 +30,7 @@ import com.volmit.iris.engine.IrisWorlds;
|
||||
import com.volmit.iris.engine.framework.EngineCompositeGenerator;
|
||||
import com.volmit.iris.engine.object.IrisCompat;
|
||||
import com.volmit.iris.engine.object.IrisDimension;
|
||||
import com.volmit.iris.engine.stream.utility.CachedStream2D;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
@ -233,7 +234,7 @@ public class Iris extends VolmitPlugin implements Listener {
|
||||
J.a(this::bstats);
|
||||
J.s(this::splash, 20);
|
||||
J.sr(this::tickQueue, 0);
|
||||
J.ar(this::checkConfigHotload, 50);
|
||||
J.ar(this::checkConfigHotload, 40);
|
||||
PaperLib.suggestPaper(this);
|
||||
getServer().getPluginManager().registerEvents(new CommandLocate(), this);
|
||||
getServer().getPluginManager().registerEvents(new WandManager(), this);
|
||||
@ -248,6 +249,15 @@ public class Iris extends VolmitPlugin implements Listener {
|
||||
configWatcher.checkModified();
|
||||
Iris.info("Hotloaded settings.json");
|
||||
}
|
||||
|
||||
int ev = CachedStream2D.evictions.get();
|
||||
if(IrisSettings.get().getGeneral().isDebug())
|
||||
{
|
||||
Iris.debug("Cache Hit Ratio: " + C.RED + Form.pc((double)CachedStream2D.cacheHits.get()/ (double)(CachedStream2D.cacheMisses.get() + CachedStream2D.cacheHits.get()), 2) + " " + C.LIGHT_PURPLE + " Evictions: " + C.AQUA + Form.f(ev/2) + "/s" + C.LIGHT_PURPLE + " Cache Size: " + C.RED + Form.f(CachedStream2D.cacheMisses.get() - CachedStream2D.evictions.get()));
|
||||
CachedStream2D.cacheMisses.addAndGet(-CachedStream2D.evictions.get());
|
||||
CachedStream2D.cacheHits.addAndGet(-CachedStream2D.evictions.get());
|
||||
CachedStream2D.evictions.set(0);
|
||||
}
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
@ -424,7 +434,7 @@ public class Iris extends VolmitPlugin implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
msg(C.LIGHT_PURPLE + "" + C.BOLD + string);
|
||||
msg(C.LIGHT_PURPLE + string);
|
||||
}
|
||||
|
||||
public static void verbose(String string) {
|
||||
|
@ -103,7 +103,7 @@ public class IrisComplex implements DataProvider {
|
||||
}
|
||||
|
||||
public IrisComplex(Engine engine, boolean simple) {
|
||||
int cacheSize = 1024;
|
||||
int cacheSize = 1024 * 128;
|
||||
this.rng = new RNG(engine.getWorld().getSeed());
|
||||
this.data = engine.getData();
|
||||
double height = engine.getHeight();
|
||||
@ -174,7 +174,7 @@ public class IrisComplex implements DataProvider {
|
||||
Interpolated.of(a -> 0D, a -> focus.getInferredType())) :
|
||||
engine.getDimension().getContinentalStyle().create(rng.nextParallelRNG(234234565))
|
||||
.bake().scale(1D / engine.getDimension().getContinentZoom()).bake().stream()
|
||||
.convert((v) -> v >= engine.getDimension().getLandChance() ? InferredType.SEA : InferredType.LAND);
|
||||
.convert((v) -> v >= engine.getDimension().getLandChance() ? InferredType.SEA : InferredType.LAND).cache2D(cacheSize);
|
||||
baseBiomeStream = focus != null ? ProceduralStream.of((x, z) -> focus,
|
||||
Interpolated.of(a -> 0D, a -> focus)) :
|
||||
bridgeStream.convertAware2D((t, x, z) -> t.equals(InferredType.SEA)
|
||||
@ -201,19 +201,19 @@ public class IrisComplex implements DataProvider {
|
||||
heightFluidStream = heightStream.max(fluidHeight).cache2D(cacheSize);
|
||||
maxHeightStream = ProceduralStream.ofDouble((x, z) -> height);
|
||||
terrainSurfaceDecoration = trueBiomeStream
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, DecorationPart.NONE));
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, DecorationPart.NONE)).cache2D(cacheSize);
|
||||
terrainCeilingDecoration = trueBiomeStream
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, DecorationPart.CEILING));
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, DecorationPart.CEILING)).cache2D(cacheSize);
|
||||
terrainCaveSurfaceDecoration = caveBiomeStream
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, DecorationPart.NONE));
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, DecorationPart.NONE)).cache2D(cacheSize);
|
||||
terrainCaveCeilingDecoration = caveBiomeStream
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, DecorationPart.CEILING));
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, DecorationPart.CEILING)).cache2D(cacheSize);
|
||||
shoreSurfaceDecoration = trueBiomeStream
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, DecorationPart.SHORE_LINE));
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, DecorationPart.SHORE_LINE)).cache2D(cacheSize);
|
||||
seaSurfaceDecoration = trueBiomeStream
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, DecorationPart.SEA_SURFACE));
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, DecorationPart.SEA_SURFACE)).cache2D(cacheSize);
|
||||
seaFloorDecoration = trueBiomeStream
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, DecorationPart.SEA_FLOOR));
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, DecorationPart.SEA_FLOOR)).cache2D(cacheSize);
|
||||
trueHeightStream = ProceduralStream.of((x, z) -> {
|
||||
int rx = (int) Math.round(engine.modifyX(x));
|
||||
int rz = (int) Math.round(engine.modifyZ(z));
|
||||
|
@ -29,6 +29,7 @@ import com.volmit.iris.util.format.Form;
|
||||
import com.volmit.iris.util.math.M;
|
||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -114,14 +115,16 @@ public class ObjectResourceLoader extends ResourceLoader<IrisObject> {
|
||||
public IrisObject loadFile(File j, String key, String name) {
|
||||
lock.lock();
|
||||
try {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
IrisObject t = new IrisObject(0, 0, 0);
|
||||
t.read(j);
|
||||
loadCache.put(key, t);
|
||||
logLoad(j);
|
||||
t.setLoadKey(name);
|
||||
t.setLoader(manager);
|
||||
t.setLoadFile(j);
|
||||
logLoad(j, t);
|
||||
lock.unlock();
|
||||
tlt.addAndGet(p.getMilliseconds());
|
||||
return t;
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
|
@ -18,9 +18,11 @@
|
||||
|
||||
package com.volmit.iris.engine.data.loader;
|
||||
|
||||
import com.google.common.util.concurrent.AtomicDouble;
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisDataManager;
|
||||
import com.volmit.iris.engine.hunk.storage.AtomicDoubleHunk;
|
||||
import com.volmit.iris.engine.object.IrisRegistrant;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
@ -31,6 +33,7 @@ import com.volmit.iris.util.io.IO;
|
||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||
import com.volmit.iris.util.scheduling.IrisLock;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.File;
|
||||
@ -38,6 +41,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@Data
|
||||
public class ResourceLoader<T extends IrisRegistrant> {
|
||||
public static final AtomicDouble tlt = new AtomicDouble(0);
|
||||
protected File root;
|
||||
protected String folderName;
|
||||
protected String resourceTypeName;
|
||||
@ -64,9 +68,10 @@ public class ResourceLoader<T extends IrisRegistrant> {
|
||||
this.root = root;
|
||||
this.folderName = folderName;
|
||||
loadCache = new KMap<>();
|
||||
Iris.debug("Loader<" + C.GREEN + resourceTypeName + C.LIGHT_PURPLE + "> created in " + C.RED + "IDM/" + manager.getId() + C.LIGHT_PURPLE + " on " + C.WHITE + manager.getDataFolder().getPath());
|
||||
}
|
||||
|
||||
public void logLoad(File path) {
|
||||
public void logLoad(File path, T t) {
|
||||
loads.getAndIncrement();
|
||||
|
||||
if (loads.get() == 1) {
|
||||
@ -79,6 +84,8 @@ public class ResourceLoader<T extends IrisRegistrant> {
|
||||
loads.set(0);
|
||||
});
|
||||
}
|
||||
|
||||
Iris.debug("Loader<" + C.GREEN + resourceTypeName + C.LIGHT_PURPLE + "> iload " + C.YELLOW + t.getLoadKey() + C.LIGHT_PURPLE + " in " + C.GRAY + t.getLoadFile().getPath() + C.LIGHT_PURPLE + " TLT: " + C.RED + Form.duration(tlt.get(), 2));
|
||||
}
|
||||
|
||||
public void failLoad(File path, Throwable e) {
|
||||
@ -118,13 +125,15 @@ public class ResourceLoader<T extends IrisRegistrant> {
|
||||
|
||||
protected T loadFile(File j, String key, String name) {
|
||||
try {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
T t = new Gson().fromJson(IO.readAll(j), objectClass);
|
||||
loadCache.put(key, t);
|
||||
logLoad(j);
|
||||
t.setLoadKey(name);
|
||||
t.setLoadFile(j);
|
||||
t.setLoader(manager);
|
||||
logLoad(j, t);
|
||||
lock.unlock();
|
||||
tlt.addAndGet(p.getMilliseconds());
|
||||
return t;
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
|
@ -38,12 +38,15 @@ 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.fakenews.FakeWorld;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
import com.volmit.iris.util.io.ReactiveFolder;
|
||||
import com.volmit.iris.util.math.M;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
import com.volmit.iris.util.reflect.V;
|
||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||
import io.netty.util.internal.ConcurrentSet;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import lombok.Getter;
|
||||
@ -453,9 +456,17 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
||||
@NotNull
|
||||
@Override
|
||||
public ChunkData generateChunkData(@NotNull World world, @NotNull Random ignored, int x, int z, @NotNull BiomeGrid biome) {
|
||||
PrecisionStopwatch ps = PrecisionStopwatch.start();
|
||||
TerrainChunk tc = TerrainChunk.create(world, biome);
|
||||
generateChunkRawData(world, x, z, tc).run();
|
||||
generated++;
|
||||
ps.end();
|
||||
|
||||
if(IrisSettings.get().getGeneral().isDebug())
|
||||
{
|
||||
Iris.debug("Chunk " + C.GREEN + x + "," + z + C.LIGHT_PURPLE + " in " + C.YELLOW + Form.duration(ps.getMillis(), 2) + C.LIGHT_PURPLE + " Rate: " + C.BLUE + Form.f(getGeneratedPerSecond(), 0) + "/s");
|
||||
}
|
||||
|
||||
return tc.getRaw();
|
||||
}
|
||||
|
||||
|
@ -24,9 +24,14 @@ import com.volmit.iris.engine.cache.Cache;
|
||||
import com.volmit.iris.engine.stream.BasicStream;
|
||||
import com.volmit.iris.engine.stream.ProceduralStream;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class CachedStream2D<T> extends BasicStream<T> implements ProceduralStream<T> {
|
||||
private final ProceduralStream<T> stream;
|
||||
private final ConcurrentLinkedHashMap<Long, T> cache;
|
||||
public static final AtomicInteger cacheHits = new AtomicInteger();
|
||||
public static final AtomicInteger cacheMisses = new AtomicInteger();
|
||||
public static final AtomicInteger evictions = new AtomicInteger();
|
||||
|
||||
public CachedStream2D(ProceduralStream<T> stream, int size) {
|
||||
super();
|
||||
@ -35,6 +40,7 @@ public class CachedStream2D<T> extends BasicStream<T> implements ProceduralStrea
|
||||
.initialCapacity(size)
|
||||
.maximumWeightedCapacity(size)
|
||||
.concurrencyLevel(32)
|
||||
.listener((k, v) -> evictions.incrementAndGet())
|
||||
.build();
|
||||
}
|
||||
|
||||
@ -55,7 +61,16 @@ public class CachedStream2D<T> extends BasicStream<T> implements ProceduralStrea
|
||||
return stream.get((int) x, (int) z);
|
||||
}
|
||||
|
||||
return cache.compute(Cache.key((int) x, (int) z), (k, v) -> v != null ? v : stream.get((int) x, (int) z));
|
||||
return cache.compute(Cache.key((int) x, (int) z), (k, v) -> {
|
||||
if(v != null )
|
||||
{
|
||||
cacheHits.incrementAndGet();
|
||||
return v;
|
||||
}
|
||||
|
||||
cacheMisses.incrementAndGet();
|
||||
return stream.get((int) x, (int) z);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user