mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-06-17 06:11:06 +00:00
increase unload speed
This commit is contained in:
@@ -52,6 +52,7 @@ dependencies {
|
|||||||
implementation 'org.apache.logging.log4j:log4j-core:2.19.0'
|
implementation 'org.apache.logging.log4j:log4j-core:2.19.0'
|
||||||
implementation 'commons-lang:commons-lang:2.6'
|
implementation 'commons-lang:commons-lang:2.6'
|
||||||
implementation 'com.github.oshi:oshi-core:5.8.5'
|
implementation 'com.github.oshi:oshi-core:5.8.5'
|
||||||
|
compileOnly 'org.lz4:lz4-java:1.8.0'
|
||||||
|
|
||||||
// Third Party Integrations
|
// Third Party Integrations
|
||||||
implementation 'com.ticxo.playeranimator:PlayerAnimator:R1.2.7'
|
implementation 'com.ticxo.playeranimator:PlayerAnimator:R1.2.7'
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import com.volmit.iris.engine.framework.Engine;
|
|||||||
import com.volmit.iris.engine.mantle.EngineMantle;
|
import com.volmit.iris.engine.mantle.EngineMantle;
|
||||||
import com.volmit.iris.engine.mantle.MantleWriter;
|
import com.volmit.iris.engine.mantle.MantleWriter;
|
||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
import com.volmit.iris.util.collection.KSet;
|
|
||||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||||
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
||||||
import com.volmit.iris.util.documentation.RegionCoordinates;
|
import com.volmit.iris.util.documentation.RegionCoordinates;
|
||||||
@@ -40,7 +39,6 @@ import com.volmit.iris.util.matter.MatterSlice;
|
|||||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||||
import com.volmit.iris.util.parallel.HyperLock;
|
import com.volmit.iris.util.parallel.HyperLock;
|
||||||
import com.volmit.iris.util.parallel.MultiBurst;
|
import com.volmit.iris.util.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.scheduling.Looper;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
|
|
||||||
@@ -112,7 +110,7 @@ public class Mantle {
|
|||||||
* @return the file
|
* @return the file
|
||||||
*/
|
*/
|
||||||
public static File fileForRegion(File folder, Long key) {
|
public static File fileForRegion(File folder, Long key) {
|
||||||
File f = new File(folder, "p." + key + ".ttp");
|
File f = new File(folder, "p." + key + ".ttp.lz4");
|
||||||
if (!f.getParentFile().exists()) {
|
if (!f.getParentFile().exists()) {
|
||||||
f.getParentFile().mkdirs();
|
f.getParentFile().mkdirs();
|
||||||
}
|
}
|
||||||
@@ -447,10 +445,11 @@ public class Mantle {
|
|||||||
AtomicInteger i = new AtomicInteger();
|
AtomicInteger i = new AtomicInteger();
|
||||||
Set<Long> toUnload = this.toUnload;
|
Set<Long> toUnload = this.toUnload;
|
||||||
this.toUnload = new HashSet<>();
|
this.toUnload = new HashSet<>();
|
||||||
|
toUnload.removeIf(Objects::isNull);
|
||||||
try {
|
try {
|
||||||
List<Future<?>> futures = new ArrayList<>();
|
List<Future<?>> futures = new ArrayList<>();
|
||||||
ExecutorService service = Executors.newFixedThreadPool(dynamicThreads.get());
|
ExecutorService service = Executors.newFixedThreadPool(dynamicThreads.get());
|
||||||
for (Long id : new ArrayList<>(toUnload)) {
|
for (long id : new ArrayList<>(toUnload)) {
|
||||||
futures.add(service.submit(() ->
|
futures.add(service.submit(() ->
|
||||||
hyperLock.withLong(id, () -> {
|
hyperLock.withLong(id, () -> {
|
||||||
TectonicPlate m = loadedRegions.get(id);
|
TectonicPlate m = loadedRegions.get(id);
|
||||||
@@ -468,10 +467,13 @@ public class Mantle {
|
|||||||
}
|
}
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
while (!futures.isEmpty()) {
|
|
||||||
futures.remove(0).get();
|
try {
|
||||||
}
|
while (!futures.isEmpty()) {
|
||||||
service.shutdown();
|
futures.remove(0).get();
|
||||||
|
}
|
||||||
|
service.shutdown();
|
||||||
|
} catch (InterruptedException ignored) {}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
@@ -549,6 +551,8 @@ public class Mantle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
File file = fileForRegion(dataFolder, x, z);
|
File file = fileForRegion(dataFolder, x, z);
|
||||||
|
if (!file.exists())
|
||||||
|
file = new File(dataFolder, file.getName().substring(".lz4".length()));
|
||||||
|
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ import com.volmit.iris.util.format.C;
|
|||||||
import com.volmit.iris.util.format.Form;
|
import com.volmit.iris.util.format.Form;
|
||||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||||
|
import net.jpountz.lz4.LZ4FrameInputStream;
|
||||||
|
import net.jpountz.lz4.LZ4FrameOutputStream;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||||
@@ -79,8 +82,14 @@ public class TectonicPlate {
|
|||||||
|
|
||||||
public static TectonicPlate read(int worldHeight, File file) throws IOException, ClassNotFoundException {
|
public static TectonicPlate read(int worldHeight, File file) throws IOException, ClassNotFoundException {
|
||||||
FileInputStream fin = new FileInputStream(file);
|
FileInputStream fin = new FileInputStream(file);
|
||||||
GZIPInputStream gzi = new GZIPInputStream(fin);
|
DataInputStream din;
|
||||||
DataInputStream din = new DataInputStream(gzi);
|
if (file.getName().endsWith("ttp")) {
|
||||||
|
GZIPInputStream gzi = new GZIPInputStream(fin);
|
||||||
|
din = new DataInputStream(gzi);
|
||||||
|
} else {
|
||||||
|
LZ4FrameInputStream lz4 = new LZ4FrameInputStream(fin);
|
||||||
|
din = new DataInputStream(lz4);
|
||||||
|
}
|
||||||
TectonicPlate p = new TectonicPlate(worldHeight, din);
|
TectonicPlate p = new TectonicPlate(worldHeight, din);
|
||||||
din.close();
|
din.close();
|
||||||
|
|
||||||
@@ -164,8 +173,14 @@ public class TectonicPlate {
|
|||||||
public void write(File file) throws IOException {
|
public void write(File file) throws IOException {
|
||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
FileOutputStream fos = new FileOutputStream(file);
|
FileOutputStream fos = new FileOutputStream(file);
|
||||||
GZIPOutputStream gzo = new GZIPOutputStream(fos);
|
DataOutputStream dos;
|
||||||
DataOutputStream dos = new DataOutputStream(gzo);
|
if (file.getName().endsWith("ttp")) {
|
||||||
|
GZIPOutputStream gzo = new GZIPOutputStream(fos);
|
||||||
|
dos = new DataOutputStream(gzo);
|
||||||
|
} else {
|
||||||
|
LZ4FrameOutputStream lz4 = new LZ4FrameOutputStream(fos);
|
||||||
|
dos = new DataOutputStream(lz4);
|
||||||
|
}
|
||||||
write(dos);
|
write(dos);
|
||||||
dos.close();
|
dos.close();
|
||||||
Iris.info("Saved Tectonic Plate " + C.DARK_GREEN + file.getName().split("\\Q.\\E")[0] + C.RED + " in " + Form.duration(p.getMilliseconds(), 2));
|
Iris.info("Saved Tectonic Plate " + C.DARK_GREEN + file.getName().split("\\Q.\\E")[0] + C.RED + " in " + Form.duration(p.getMilliseconds(), 2));
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ libraries:
|
|||||||
- org.ow2.asm:asm:9.2
|
- org.ow2.asm:asm:9.2
|
||||||
- rhino:js:1.7R2
|
- rhino:js:1.7R2
|
||||||
- bsf:bsf:2.4.0
|
- bsf:bsf:2.4.0
|
||||||
|
- org.lz4:lz4-java:1.8.0
|
||||||
commands:
|
commands:
|
||||||
iris:
|
iris:
|
||||||
aliases: [ ir, irs ]
|
aliases: [ ir, irs ]
|
||||||
|
|||||||
Reference in New Issue
Block a user