Multi IO threads w/ fixes default config value
This commit is contained in:
@@ -15,6 +15,7 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
@SuppressWarnings({"UnusedIsStillUsed", "unused"})
|
||||
public class AkarinGlobalConfig {
|
||||
public final static Logger LOGGER = LogManager.getLogger("Akarin");
|
||||
|
||||
@@ -143,15 +144,20 @@ public class AkarinGlobalConfig {
|
||||
return config.getString(path, config.getString(path));
|
||||
}
|
||||
/*========================================================================*/
|
||||
public static boolean noResponseDoGC;
|
||||
public static boolean noResponseDoGC = true;
|
||||
private static void noResponseDoGC() {
|
||||
noResponseDoGC = getBoolean("alternative.gc-before-stuck-restart", true);
|
||||
noResponseDoGC = getBoolean("alternative.gc-before-stuck-restart", noResponseDoGC);
|
||||
}
|
||||
|
||||
public static String serverBrandName;
|
||||
|
||||
public static String serverBrandName = "";
|
||||
private static void serverBrandName() {
|
||||
serverBrandName = getString("alternative.modified-server-brand-name", "");
|
||||
serverBrandName = getString("alternative.modified-server-brand-name", serverBrandName);
|
||||
}
|
||||
|
||||
public static int fileIOThreads = 2;
|
||||
private static void fileIOThreads() {
|
||||
fileIOThreads = getInt("core.chunk-save-threads", fileIOThreads);
|
||||
fileIOThreads = fileIOThreads < 1 ? 1 : fileIOThreads;
|
||||
fileIOThreads = fileIOThreads > 8 ? 8 : fileIOThreads;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -14,13 +17,27 @@ public class FileIOThread implements Runnable {
|
||||
private volatile long d;
|
||||
private volatile long e;
|
||||
private volatile boolean f;
|
||||
// Akarin start
|
||||
private final java.util.concurrent.ExecutorService executor = java.util.concurrent.Executors.newFixedThreadPool(io.akarin.server.core.AkarinGlobalConfig.fileIOThreads, new com.google.common.util.concurrent.ThreadFactoryBuilder().setUncaughtExceptionHandler(new ThreadNamedUncaughtExceptionHandler(FileIOThread.a)).setNameFormat("Akarin File IO Thread - %1$d").setPriority(1).build());
|
||||
|
||||
@lombok.SneakyThrows
|
||||
private void writeChunk(IAsyncChunkSaver iasyncchunksaver) {
|
||||
if (!iasyncchunksaver.a() /* writeNextIO */) { // returns whether the writing was unsuccessful
|
||||
if (com.destroystokyo.paper.PaperConfig.enableFileIOThreadSleep) { // Paper
|
||||
Thread.sleep(this.f ? 0L : 2L); // Paper
|
||||
}
|
||||
} else {
|
||||
writeChunk(iasyncchunksaver);
|
||||
}
|
||||
}
|
||||
// Akarin end
|
||||
|
||||
private FileIOThread() {
|
||||
Thread thread = new Thread(this, "File IO Thread");
|
||||
|
||||
thread.setUncaughtExceptionHandler(new ThreadNamedUncaughtExceptionHandler(FileIOThread.a));
|
||||
thread.setPriority(1);
|
||||
thread.start();
|
||||
//thread.start(); // Akarin
|
||||
}
|
||||
|
||||
public static FileIOThread a() {
|
||||
@@ -66,10 +83,13 @@ public class FileIOThread implements Runnable {
|
||||
}
|
||||
|
||||
public void a(IAsyncChunkSaver iasyncchunksaver) {
|
||||
if (!this.c.contains(iasyncchunksaver)) {
|
||||
++this.d;
|
||||
this.c.add(iasyncchunksaver);
|
||||
}
|
||||
// Akarin start
|
||||
//if (!this.c.contains(iasyncchunksaver)) {
|
||||
// ++this.d;
|
||||
// this.c.add(iasyncchunksaver);
|
||||
//}
|
||||
executor.execute(() -> writeChunk(iasyncchunksaver));
|
||||
// Akarin end
|
||||
}
|
||||
|
||||
public void b() throws InterruptedException {
|
||||
@@ -78,6 +98,8 @@ public class FileIOThread implements Runnable {
|
||||
while(!this.getThreadedIOQueue().isEmpty()) { // Paper - check actual list size
|
||||
Thread.sleep(10L);
|
||||
}
|
||||
executor.shutdown(); // Akarin
|
||||
executor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS); // Akarin
|
||||
|
||||
this.f = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user