mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-05 10:20:53 +01:00
526795bacd
* Update patches to handle vineflower decompiler * update patches again to handle inlined simple lambdas * update vf again and re-apply/rebuild patches * update patches after removal of verify-merges flag * fix compile issue * remove maven local * fix some issues * address more issues * fix collision patch * use paperweight release * more fixes * update fineflower and fix patches again * add missing comment descriptor --------- Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
67 lines
3.6 KiB
Diff
67 lines
3.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Callahan <mr.callahhh@gmail.com>
|
|
Date: Wed, 8 Apr 2020 02:42:14 -0500
|
|
Subject: [PATCH] Async command map building
|
|
|
|
This adds a custom pool inorder to make sure that they are closed
|
|
without much though, as it doesn't matter if the client is not sent
|
|
commands if the server is restarting. Using the default async pool caused issues to arise
|
|
due to the shutdown logic generally being much later.
|
|
|
|
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
|
|
index 15a5059994371da4850adcf726034a715b80efba..af7cb518a32a4d550eae833fdd5bb17fd4058717 100644
|
|
--- a/src/main/java/net/minecraft/commands/Commands.java
|
|
+++ b/src/main/java/net/minecraft/commands/Commands.java
|
|
@@ -457,6 +457,24 @@ public class Commands {
|
|
if ( org.spigotmc.SpigotConfig.tabComplete < 0 ) return; // Spigot
|
|
// CraftBukkit start
|
|
// Register Vanilla commands into builtRoot as before
|
|
+ // Paper start - Perf: Async command map building
|
|
+ COMMAND_SENDING_POOL.execute(() -> {
|
|
+ this.sendAsync(player);
|
|
+ });
|
|
+ }
|
|
+
|
|
+ public static final java.util.concurrent.ThreadPoolExecutor COMMAND_SENDING_POOL = new java.util.concurrent.ThreadPoolExecutor(
|
|
+ 0, 2, 60L, java.util.concurrent.TimeUnit.SECONDS,
|
|
+ new java.util.concurrent.LinkedBlockingQueue<>(),
|
|
+ new com.google.common.util.concurrent.ThreadFactoryBuilder()
|
|
+ .setNameFormat("Paper Async Command Builder Thread Pool - %1$d")
|
|
+ .setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(net.minecraft.server.MinecraftServer.LOGGER))
|
|
+ .build(),
|
|
+ new java.util.concurrent.ThreadPoolExecutor.DiscardPolicy()
|
|
+ );
|
|
+
|
|
+ private void sendAsync(ServerPlayer player) {
|
|
+ // Paper end - Perf: Async command map building
|
|
Map<CommandNode<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> map = Maps.newIdentityHashMap(); // Use identity to prevent aliasing issues
|
|
RootCommandNode vanillaRoot = new RootCommandNode();
|
|
|
|
@@ -474,7 +492,14 @@ public class Commands {
|
|
for (CommandNode node : rootcommandnode.getChildren()) {
|
|
bukkit.add(node.getName());
|
|
}
|
|
+ // Paper start - Perf: Async command map building
|
|
+ net.minecraft.server.MinecraftServer.getServer().execute(() -> {
|
|
+ runSync(player, bukkit, rootcommandnode);
|
|
+ });
|
|
+ }
|
|
|
|
+ private void runSync(ServerPlayer player, Collection<String> bukkit, RootCommandNode<SharedSuggestionProvider> rootcommandnode) {
|
|
+ // Paper end - Perf: Async command map building
|
|
PlayerCommandSendEvent event = new PlayerCommandSendEvent(player.getBukkitEntity(), new LinkedHashSet<>(bukkit));
|
|
event.getPlayer().getServer().getPluginManager().callEvent(event);
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
index 4cacf5cc0750f017824e9d8737d3c490324b49dd..fea2863dc00d9765b86ac4cf925ceaf0fbef7da3 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -916,6 +916,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
}
|
|
|
|
MinecraftServer.LOGGER.info("Stopping server");
|
|
+ Commands.COMMAND_SENDING_POOL.shutdownNow(); // Paper - Perf: Async command map building; Shutdown and don't bother finishing
|
|
MinecraftTimings.stopServer(); // Paper
|
|
// CraftBukkit start
|
|
if (this.server != null) {
|