mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 02:36:59 +00:00
Fix the leak
This commit is contained in:
parent
5878128746
commit
56ae387f7b
@ -401,4 +401,16 @@ public interface IrisAccess extends Hotloadable, DataProvider {
|
||||
int getPrecacheSize();
|
||||
|
||||
Chunk generatePaper(World world, int cx, int cz);
|
||||
|
||||
default int getParallaxChunkCount()
|
||||
{
|
||||
int v= 0;
|
||||
|
||||
for(int i = 0; i < getCompound().getSize(); i++)
|
||||
{
|
||||
v += getCompound().getEngine(i).getParallax().getChunkCount();
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,8 @@ package com.volmit.iris.scaffold.hunk.io;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import com.volmit.iris.scaffold.parallel.BurstExecutor;
|
||||
import com.volmit.iris.scaffold.parallel.MultiBurst;
|
||||
import com.volmit.iris.util.*;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
@ -78,12 +80,19 @@ public class HunkRegionSlice<T>
|
||||
|
||||
public void save()
|
||||
{
|
||||
BurstExecutor e = MultiBurst.burst.burst(save.size());
|
||||
for(ChunkPosition i : save.copy())
|
||||
{
|
||||
save(i.getX(), i.getZ());
|
||||
if(i == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
e.queue(() -> save(i.getX(), i.getZ()));
|
||||
save.remove(i);
|
||||
}
|
||||
|
||||
save.clear();
|
||||
e.complete();
|
||||
}
|
||||
|
||||
public boolean contains(int x, int z)
|
||||
|
@ -1,9 +1,11 @@
|
||||
package com.volmit.iris.scaffold.parallax;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import com.volmit.iris.util.*;
|
||||
import com.volmit.iris.util.ChronoLatch;
|
||||
import com.volmit.iris.util.J;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.KMap;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.io.File;
|
||||
@ -23,7 +25,7 @@ public class ParallaxWorld implements ParallaxAccess
|
||||
this.folder = folder;
|
||||
save = new KList<>();
|
||||
loadedRegions = new KMap<>();
|
||||
cleanup = new ChronoLatch(1000);
|
||||
cleanup = new ChronoLatch(5000);
|
||||
folder.mkdirs();
|
||||
}
|
||||
|
||||
@ -101,12 +103,12 @@ public class ParallaxWorld implements ParallaxAccess
|
||||
save.remove(key);
|
||||
}
|
||||
|
||||
v += loadedRegions.remove(key).unload();
|
||||
}
|
||||
ParallaxRegion lr = loadedRegions.remove(key);
|
||||
|
||||
else
|
||||
{
|
||||
Iris.warn("Cant unload region " + x + " " + z + " because it's not loaded.");
|
||||
if(lr != null)
|
||||
{
|
||||
v += lr.unload();
|
||||
}
|
||||
}
|
||||
|
||||
return v;
|
||||
@ -210,28 +212,31 @@ public class ParallaxWorld implements ParallaxAccess
|
||||
|
||||
@Override
|
||||
public void cleanup(long r, long c) {
|
||||
|
||||
J.a(() -> {
|
||||
int rr = 0;
|
||||
int cc = 0;
|
||||
|
||||
for(ParallaxRegion i : loadedRegions.v())
|
||||
try
|
||||
{
|
||||
if(i.hasBeenIdleLongerThan(r))
|
||||
{
|
||||
rr++;
|
||||
unload(i.getX(), i.getZ());
|
||||
}
|
||||
int rr = 0;
|
||||
int cc = 0;
|
||||
|
||||
else
|
||||
for(ParallaxRegion i : loadedRegions.v())
|
||||
{
|
||||
cc+= i.cleanup(c);
|
||||
if(i.hasBeenIdleLongerThan(r))
|
||||
{
|
||||
rr++;
|
||||
unload(i.getX(), i.getZ());
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
cc+= i.cleanup(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Iris.info("Unloaded " + rr + " Regions and " + cc + " Chunks");
|
||||
Iris.info("P: c" + Form.f(getChunkCount()) + " / r" + getRegionCount());
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ public class MultiBurst
|
||||
tid++;
|
||||
Thread t = new Thread(r);
|
||||
t.setName("Iris Generator " + tid);
|
||||
t.setPriority(Thread.MAX_PRIORITY);
|
||||
t.setPriority(6);
|
||||
t.setUncaughtExceptionHandler((et, e) ->
|
||||
{
|
||||
Iris.info("Exception encountered in " + et.getName());
|
||||
|
@ -19,7 +19,7 @@ public class J
|
||||
tid++;
|
||||
Thread t = new Thread(r);
|
||||
t.setName("Iris Actuator " + tid);
|
||||
t.setPriority(Thread.MIN_PRIORITY);
|
||||
t.setPriority(8);
|
||||
t.setUncaughtExceptionHandler((et, e) ->
|
||||
{
|
||||
Iris.info("Exception encountered in " + et.getName());
|
||||
|
@ -18,7 +18,10 @@ import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class PregenJob implements Listener
|
||||
@ -53,7 +56,7 @@ public class PregenJob implements Listener
|
||||
private double cps = 0;
|
||||
private int lg = 0;
|
||||
private long lt = M.ms();
|
||||
private int cubeSize = 9;
|
||||
private int cubeSize = 32;
|
||||
private long nogen = M.ms();
|
||||
private KList<ChunkPosition> requeueMCA = new KList<ChunkPosition>();
|
||||
private RollingSequence acps = new RollingSequence(PaperLib.isPaper() ? 8 : 32);
|
||||
@ -64,6 +67,25 @@ public class PregenJob implements Listener
|
||||
private final DirectWorldWriter writer;
|
||||
int xc = 0;
|
||||
private IrisAccess access = null;
|
||||
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 Pregen Worker " + tid);
|
||||
t.setPriority(3);
|
||||
t.setUncaughtExceptionHandler((et, e) ->
|
||||
{
|
||||
Iris.info("Exception encountered in " + et.getName());
|
||||
e.printStackTrace();
|
||||
});
|
||||
|
||||
return t;
|
||||
}
|
||||
});
|
||||
|
||||
public PregenJob(World world, int size, MortarSender sender, Runnable onDone)
|
||||
{
|
||||
@ -439,7 +461,7 @@ public class PregenJob implements Listener
|
||||
}
|
||||
};
|
||||
|
||||
J.a(g);
|
||||
e.execute(g);
|
||||
}
|
||||
|
||||
else
|
||||
@ -447,7 +469,7 @@ public class PregenJob implements Listener
|
||||
{
|
||||
consumer.accept(new ChunkPosition(chunkX, chunkZ), Color.magenta.darker().darker().darker());
|
||||
}
|
||||
J.a(() ->
|
||||
e.execute(() ->
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -626,7 +648,7 @@ public class PregenJob implements Listener
|
||||
try
|
||||
{
|
||||
vv.add("Parallelism: " + access().getCompound().getCurrentlyGeneratingEngines());
|
||||
vv.add("Precache : " + access().getPrecacheSize());
|
||||
vv.add("Plax Cache : " + Form.f(access().getParallaxChunkCount()));
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
|
Loading…
x
Reference in New Issue
Block a user