Add Suki 0015
This commit is contained in:
@@ -11,6 +11,7 @@ You can find the original code on https://github.com/SuCraft/Suki
|
||||
0016-Send-more-packets-immediately.patch
|
||||
0017-Flush-after-more-packets.patch
|
||||
0018-Do-not-relocate-corrupted-chunks.patch
|
||||
0015-Multithreading environment variables.patch
|
||||
|
||||
diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java
|
||||
index 2cc44fbf8e5bd436b6d4e19f6c06b351e750cb31..991b06836df310913a14ce1c60979a2c2944b0e5 100644
|
||||
@@ -226,6 +227,56 @@ index e731de3ac158c5a4cff236c6f5001674cd488a77..06a6cecfa01c676285ea894c3ed77d0e
|
||||
+ }
|
||||
+ // Suki end - Suki configuration
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java
|
||||
index b759f82b265542f42821e35ead56a5c073625d36..f93cbf0812801bb503db26e623d988e4eeb8b126 100644
|
||||
--- a/src/main/java/net/minecraft/Util.java
|
||||
+++ b/src/main/java/net/minecraft/Util.java
|
||||
@@ -27,7 +27,6 @@ import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.spi.FileSystemProvider;
|
||||
-import java.security.AccessController;
|
||||
import java.security.PrivilegedActionException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.time.Duration;
|
||||
@@ -151,9 +150,15 @@ public class Util {
|
||||
}
|
||||
|
||||
private static ExecutorService makeExecutor(String s, int priorityModifier) { // Paper - add priority
|
||||
+ // Suki start - multithreading environment variables
|
||||
+ return makeExecutor(s, priorityModifier, -1);
|
||||
+ }
|
||||
+
|
||||
+ public static ExecutorService makeExecutor(String s, int priorityModifier, int specificThreads) {
|
||||
+ // Suki end - multithreading environment variables
|
||||
// Paper start - use simpler thread pool that allows 1 thread
|
||||
// Paper start - also try to avoid suffocating the system with the worldgen workers
|
||||
- int cpus = Runtime.getRuntime().availableProcessors() / 2;
|
||||
+ int cpus = Integer.getInteger("suki.systemcpus.forexecutors", Runtime.getRuntime().availableProcessors() / 2); // Suki - multithreading environment variables
|
||||
int i;
|
||||
if (cpus <= 4) {
|
||||
i = cpus <= 2 ? 1 : 2;
|
||||
@@ -166,6 +171,11 @@ public class Util {
|
||||
i = Math.min(8, i);
|
||||
// Paper end - also try to avoid suffocating the system with the worldgen workers
|
||||
i = Integer.getInteger("Paper.WorkerThreadCount", i);
|
||||
+ // Suki start - multithreading environment variables
|
||||
+ if (specificThreads > 0) {
|
||||
+ i = specificThreads;
|
||||
+ }
|
||||
+ // Suki end - multithreading environment variables
|
||||
ExecutorService executorService;
|
||||
|
||||
if (i <= 0) {
|
||||
@@ -173,7 +183,7 @@ public class Util {
|
||||
} else {
|
||||
//executorService = new java.util.concurrent.ThreadPoolExecutor(i, i,0L, TimeUnit.MILLISECONDS, new java.util.concurrent.LinkedBlockingQueue<Runnable>(), target -> new net.minecraft.server.ServerWorkerThread(target, s, priorityModifier)); // JettPack
|
||||
// JettPack start
|
||||
- executorService = Integer.getInteger("Paper.WorkerThreadCount", i) <= 0 ? MoreExecutors.newDirectExecutorService() : new AbstractExecutorService(){
|
||||
+ executorService = new AbstractExecutorService(){ // Suki - multithreading environment variables
|
||||
private volatile boolean shutdown = false;
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
|
||||
index e1563410e0711de5cf9363978125e637929392da..948e988cdcf3edb0ceb0bd397d0579a1784d9ae1 100644
|
||||
--- a/src/main/java/net/minecraft/network/Connection.java
|
||||
@@ -260,8 +311,36 @@ index e1563410e0711de5cf9363978125e637929392da..948e988cdcf3edb0ceb0bd397d0579a1
|
||||
// Paper end - add flush parameter
|
||||
ConnectionProtocol enumprotocol = ConnectionProtocol.getProtocolForPacket(packet);
|
||||
ConnectionProtocol enumprotocol1 = this.getCurrentProtocol();
|
||||
diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java
|
||||
index 07b0b0993c01763b39d1c9a387447ec76b5de190..72e700a775403eec2d1a32859279401351b836b1 100644
|
||||
--- a/src/main/java/net/minecraft/server/MCUtil.java
|
||||
+++ b/src/main/java/net/minecraft/server/MCUtil.java
|
||||
@@ -55,8 +55,8 @@ import java.util.function.Supplier;
|
||||
|
||||
public final class MCUtil {
|
||||
public static final ThreadPoolExecutor asyncExecutor = new ThreadPoolExecutor(
|
||||
- 0, 2, 60L, TimeUnit.SECONDS,
|
||||
- new LinkedBlockingQueue<>(),
|
||||
+ Integer.getInteger("suki.threads.asyncexecutor", 4), Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, // JettPack // Suki - multithreading environment variables
|
||||
+ new LinkedBlockingQueue<>(),
|
||||
new ThreadFactoryBuilder()
|
||||
.setNameFormat("Paper Async Task Handler Thread - %1$d")
|
||||
.setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(MinecraftServer.LOGGER))
|
||||
diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java
|
||||
index 5962f7a2b185d7d54a0f9e341a4fdf6e6f1c1ec5..8c80520396bc7e34bac25354c1fcdb38b71000c7 100644
|
||||
--- a/src/main/java/net/minecraft/server/Main.java
|
||||
+++ b/src/main/java/net/minecraft/server/Main.java
|
||||
@@ -318,7 +318,7 @@ public class Main {
|
||||
// Paper start - fix and optimise world upgrading
|
||||
public static void convertWorldButItWorks(net.minecraft.resources.ResourceKey<net.minecraft.world.level.dimension.LevelStem> dimensionType, net.minecraft.world.level.storage.LevelStorageSource.LevelStorageAccess worldSession,
|
||||
DataFixer dataFixer, Optional<net.minecraft.resources.ResourceKey<com.mojang.serialization.Codec<? extends net.minecraft.world.level.chunk.ChunkGenerator>>> generatorKey, boolean removeCaches) {
|
||||
- int threads = Runtime.getRuntime().availableProcessors() * 3 / 8;
|
||||
+ int threads = Integer.getInteger("suki.threads.upgradeworld", Integer.getInteger("suki.systemcpus.forupgradeworld", Runtime.getRuntime().availableProcessors()) * 3 / 8); // Suki - multithreading environment variables
|
||||
final ThreadedWorldUpgrader worldUpgrader = new ThreadedWorldUpgrader(dimensionType, worldSession.getLevelId(), worldSession.levelDirectory.path().toFile(), threads, dataFixer, generatorKey, removeCaches);
|
||||
worldUpgrader.convert();
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index a444c8c57a2ab16eba45b0379841a69ff60a5586..d7be9d4e29347b492c22ed2830afc59cffe2d2bc 100644
|
||||
index a444c8c57a2ab16eba45b0379841a69ff60a5586..ede16b015b9dde07a7346e0bffde53082145798b 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -294,6 +294,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -272,7 +351,20 @@ index a444c8c57a2ab16eba45b0379841a69ff60a5586..d7be9d4e29347b492c22ed2830afc59c
|
||||
public static long currentTickLong = 0L; // Paper
|
||||
public boolean lagging = false; // Purpur
|
||||
protected boolean upnp = false; // Purpur
|
||||
@@ -400,6 +401,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -313,8 +314,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
thread.setUncaughtExceptionHandler((thread1, throwable) -> {
|
||||
MinecraftServer.LOGGER.error("Uncaught exception in server thread", throwable);
|
||||
});
|
||||
- if (Runtime.getRuntime().availableProcessors() > 4) {
|
||||
- thread.setPriority(8);
|
||||
+ // Suki start - multithreading environment variables
|
||||
+ if (Integer.getInteger("suki.mainthreadpriority", -1) != -1 || Runtime.getRuntime().availableProcessors() > 4) {
|
||||
+ thread.setPriority(Integer.getInteger("suki.mainthreadpriority", 8));
|
||||
+ // Suki end - multithreading environment variables
|
||||
}
|
||||
|
||||
S s0 = serverFactory.apply(thread); // CraftBukkit - decompile error
|
||||
@@ -400,6 +403,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
// Paper end
|
||||
Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.util.ServerShutdownThread(this));
|
||||
this.paperConfigurations = services.paperConfigurations(); // Paper
|
||||
@@ -485,10 +577,18 @@ index 34e351e04ac57e47e3cea671c61cc01d17983b77..f583ae81fb60027c47aaecdb6451462c
|
||||
|
||||
UpgradeData chunkconverter = nbt.contains("UpgradeData", 10) ? new UpgradeData(nbt.getCompound("UpgradeData"), world) : UpgradeData.EMPTY;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 4f029b96bf8deee597dbb56974e4519a1422f96d..fb28dbf080634bb5e421f08ed117cc2588e5c2a1 100644
|
||||
index 4f029b96bf8deee597dbb56974e4519a1422f96d..9e47bbefdb373a75a9903b19c23e9191b9c84846 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -1013,6 +1013,7 @@ public final class CraftServer implements Server {
|
||||
@@ -242,6 +242,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||
import org.yaml.snakeyaml.error.MarkedYAMLException;
|
||||
+import net.minecraft.Util; // KeYi
|
||||
|
||||
import net.md_5.bungee.api.chat.BaseComponent; // Spigot
|
||||
|
||||
@@ -1013,6 +1014,7 @@ public final class CraftServer implements Server {
|
||||
org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot
|
||||
this.console.paperConfigurations.reloadConfigs(this.console);
|
||||
org.purpurmc.purpur.PurpurConfig.init((File) console.options.valueOf("purpur-settings")); // Purpur
|
||||
@@ -496,7 +596,21 @@ index 4f029b96bf8deee597dbb56974e4519a1422f96d..fb28dbf080634bb5e421f08ed117cc25
|
||||
for (ServerLevel world : this.console.getAllLevels()) {
|
||||
// world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty
|
||||
world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters, config.spawnAnimals); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean))
|
||||
@@ -2840,6 +2841,13 @@ public final class CraftServer implements Server {
|
||||
@@ -1295,9 +1297,11 @@ public final class CraftServer implements Server {
|
||||
worldKey = ResourceKey.create(net.minecraft.core.Registry.DIMENSION_REGISTRY, new net.minecraft.resources.ResourceLocation(creator.key().getNamespace().toLowerCase(java.util.Locale.ENGLISH), creator.key().getKey().toLowerCase(java.util.Locale.ENGLISH))); // Paper
|
||||
}
|
||||
|
||||
- ServerLevel internal = (ServerLevel) new ServerLevel(this.console, console.executor, worldSession, worlddata, worldKey, worlddimension, this.getServer().progressListenerFactory.create(11),
|
||||
+ // Suki start - multithreading environment variables
|
||||
+ int levelExecutorThreads = Integer.getInteger("suki.threads.levelexecutor", -1);
|
||||
+ ServerLevel internal = (ServerLevel) new ServerLevel(this.console, levelExecutorThreads > 0 ? Util.makeExecutor(name, -1, levelExecutorThreads) : console.executor, worldSession, worlddata, worldKey, worlddimension, this.getServer().progressListenerFactory.create(11),
|
||||
worlddata.worldGenSettings().isDebug(), j, creator.environment() == Environment.NORMAL ? list : ImmutableList.of(), true, creator.environment(), generator, biomeProvider);
|
||||
-
|
||||
+ // Suki end - multithreading environment variables
|
||||
if (!(this.worlds.containsKey(name.toLowerCase(java.util.Locale.ENGLISH)))) {
|
||||
return null;
|
||||
}
|
||||
@@ -2840,6 +2844,13 @@ public final class CraftServer implements Server {
|
||||
return CraftServer.this.console.paperConfigurations.createLegacyObject(CraftServer.this.console);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user