Paper/patches/server/0239-Use-a-Queue-for-Queueing-Commands.patch

40 Zeilen
2.2 KiB
Diff

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 12 Aug 2018 02:33:39 -0400
Subject: [PATCH] Use a Queue for Queueing Commands
Lists are bad as Queues mmmkay.
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
2023-10-27 01:34:58 +02:00
index e3754d916ce38d0e0e8b8dbb623016ee6ebf4800..7088e0fc8980dcc547d5703d21c55a26adb5d378 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
2022-12-07 20:22:28 +01:00
@@ -69,7 +69,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
2022-06-07 23:45:11 +02:00
static final Logger LOGGER = LogUtils.getLogger();
2021-06-13 01:45:00 +02:00
private static final int CONVERSION_RETRY_DELAY_MS = 5000;
private static final int CONVERSION_RETRIES = 2;
2021-06-11 14:02:28 +02:00
- private final List<ConsoleInput> consoleInput = Collections.synchronizedList(Lists.newArrayList());
2021-11-23 16:04:41 +01:00
+ private final java.util.Queue<ConsoleInput> serverCommandQueue = new java.util.concurrent.ConcurrentLinkedQueue<>(); // Paper - use a proper queuemmands
@Nullable
2021-06-11 14:02:28 +02:00
private QueryThreadGs4 queryThreadGs4;
2023-09-22 00:01:00 +02:00
// private final RemoteControlCommandListener rconConsoleSource; // CraftBukkit - remove field
2023-09-22 22:13:57 +02:00
@@ -439,13 +439,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
return;
}
// Paper end - rewrite chunk system
2021-06-11 14:02:28 +02:00
- this.consoleInput.add(new ConsoleInput(command, commandSource));
Rewrite chunk system (#8177) Patch documentation to come Issues with the old system that are fixed now: - World generation does not scale with cpu cores effectively. - Relies on the main thread for scheduling and maintaining chunk state, dropping chunk load/generate rates at lower tps. - Unreliable prioritisation of chunk gen/load calls that block the main thread. - Shutdown logic is utterly unreliable, as it has to wait for all chunks to unload - is it guaranteed that the chunk system is in a state on shutdown that it can reliably do this? Watchdog shutdown also typically failed due to thread checks, which is now resolved. - Saving of data is not unified (i.e can save chunk data without saving entity data, poses problems for desync if shutdown is really abnormal. - Entities are not loaded with chunks. This caused quite a bit of headache for Chunk#getEntities API, but now the new chunk system loads entities with chunks so that they are ready whenever the chunk loads in. Effectively brings the behavior back to 1.16 era, but still storing entities in their own separate regionfiles. The above list is not complete. The patch documentation will complete it. New chunk system hard relies on starlight and dataconverter, and most importantly the new concurrent utilities in ConcurrentUtil. Some of the old async chunk i/o interface (i.e the old file io thread reroutes _some_ calls to the new file io thread) is kept for plugin compat reasons. It will be removed in the next major version of minecraft. The old legacy chunk system patches have been moved to the removed folder in case we need them again.
2022-09-26 10:02:51 +02:00
+ this.serverCommandQueue.add(new ConsoleInput(command, commandSource)); // Paper - use proper queue
2021-06-11 14:02:28 +02:00
}
public void handleConsoleInputs() {
MinecraftTimings.serverCommandTimer.startTiming(); // Spigot
- while (!this.consoleInput.isEmpty()) {
- ConsoleInput servercommand = (ConsoleInput) this.consoleInput.remove(0);
+ // Paper start - use proper queue
+ ConsoleInput servercommand;
+ while ((servercommand = this.serverCommandQueue.poll()) != null) {
+ // Paper end
// CraftBukkit start - ServerCommand for preprocessing
2023-10-27 01:34:58 +02:00
ServerCommandEvent event = new ServerCommandEvent(this.console, servercommand.msg);