diff options
author | Nassim Jahnke <[email protected]> | 2024-11-30 10:44:57 +0100 |
---|---|---|
committer | Nassim Jahnke <[email protected]> | 2024-11-30 10:44:57 +0100 |
commit | 9039c3923c1210f82c7246cc686949ee1c037be8 (patch) | |
tree | 85d5f28b9ce97943fae92486eca8db1b93251250 | |
parent | 47f207135044e8835c529561d0d0029f0ae3fba8 (diff) | |
download | Paper-9039c3923c1210f82c7246cc686949ee1c037be8.tar.gz Paper-9039c3923c1210f82c7246cc686949ee1c037be8.zip |
Add back discard policy
4 files changed, 22 insertions, 18 deletions
diff --git a/patches/server/0273-Async-command-map-building.patch b/patches/server/0273-Async-command-map-building.patch index 516cb43ecf..5fb46253e8 100644 --- a/patches/server/0273-Async-command-map-building.patch +++ b/patches/server/0273-Async-command-map-building.patch @@ -9,10 +9,10 @@ commands if the server is restarting. Using the default async pool caused issues 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 2008fd542eaf1c2fac776ae1751c227a3b6dde4b..938db2436e0f099432263aba593e684eb89a44f9 100644 +index 2008fd542eaf1c2fac776ae1751c227a3b6dde4b..6212d94503023f7bb5ca21785cbb69babe4421c3 100644 --- a/src/main/java/net/minecraft/commands/Commands.java +++ b/src/main/java/net/minecraft/commands/Commands.java -@@ -455,6 +455,21 @@ public class Commands { +@@ -455,6 +455,25 @@ public class Commands { if ( org.spigotmc.SpigotConfig.tabComplete < 0 ) return; // Spigot // CraftBukkit start // Register Vanilla commands into builtRoot as before @@ -22,11 +22,15 @@ index 2008fd542eaf1c2fac776ae1751c227a3b6dde4b..938db2436e0f099432263aba593e684e + COMMAND_SENDING_POOL.execute(() -> this.sendAsync(player, commandNodes)); + } + -+ public static final java.util.concurrent.ExecutorService COMMAND_SENDING_POOL = java.util.concurrent.Executors.newFixedThreadPool(2, ++ // Fixed pool, but with discard policy ++ public static final java.util.concurrent.ExecutorService COMMAND_SENDING_POOL = new java.util.concurrent.ThreadPoolExecutor( ++ 2, 2, 0, java.util.concurrent.TimeUnit.MILLISECONDS, ++ 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() ++ .build(), ++ new java.util.concurrent.ThreadPoolExecutor.DiscardPolicy() + ); + + private void sendAsync(ServerPlayer player, Collection<CommandNode<CommandSourceStack>> dispatcherRootChildren) { @@ -34,7 +38,7 @@ index 2008fd542eaf1c2fac776ae1751c227a3b6dde4b..938db2436e0f099432263aba593e684e Map<CommandNode<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> map = Maps.newIdentityHashMap(); // Use identity to prevent aliasing issues RootCommandNode vanillaRoot = new RootCommandNode(); -@@ -466,13 +481,20 @@ public class Commands { +@@ -466,13 +485,20 @@ public class Commands { RootCommandNode<SharedSuggestionProvider> rootcommandnode = new RootCommandNode(); map.put(this.dispatcher.getRoot(), rootcommandnode); @@ -56,7 +60,7 @@ index 2008fd542eaf1c2fac776ae1751c227a3b6dde4b..938db2436e0f099432263aba593e684e PlayerCommandSendEvent event = new PlayerCommandSendEvent(player.getBukkitEntity(), new LinkedHashSet<>(bukkit)); event.getPlayer().getServer().getPluginManager().callEvent(event); -@@ -486,8 +508,10 @@ public class Commands { +@@ -486,8 +512,10 @@ public class Commands { player.connection.send(new ClientboundCommandsPacket(rootcommandnode)); } @@ -69,7 +73,7 @@ index 2008fd542eaf1c2fac776ae1751c227a3b6dde4b..938db2436e0f099432263aba593e684e while (iterator.hasNext()) { CommandNode<CommandSourceStack> commandnode2 = (CommandNode) iterator.next(); -@@ -522,7 +546,7 @@ public class Commands { +@@ -522,7 +550,7 @@ public class Commands { resultNodes.put(commandnode2, commandnode3); result.addChild(commandnode3); if (!commandnode2.getChildren().isEmpty()) { diff --git a/patches/server/0274-Brigadier-Mojang-API.patch b/patches/server/0274-Brigadier-Mojang-API.patch index 4c232b5a17..9925490b27 100644 --- a/patches/server/0274-Brigadier-Mojang-API.patch +++ b/patches/server/0274-Brigadier-Mojang-API.patch @@ -87,10 +87,10 @@ index 4d5f1dd1c3bd742b1bc5e3914101a699041caa7e..5316f148f3f9128690f019d544e462b0 public boolean hasPermission(int level) { // CraftBukkit start diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java -index 938db2436e0f099432263aba593e684eb89a44f9..71c8692487c9c1c5b956b4356501d523368c0507 100644 +index 6212d94503023f7bb5ca21785cbb69babe4421c3..642d5c6849debc5a266605b0df30d55222339438 100644 --- a/src/main/java/net/minecraft/commands/Commands.java +++ b/src/main/java/net/minecraft/commands/Commands.java -@@ -488,6 +488,7 @@ public class Commands { +@@ -492,6 +492,7 @@ public class Commands { bukkit.add(node.getName()); } // Paper start - Perf: Async command map building @@ -98,7 +98,7 @@ index 938db2436e0f099432263aba593e684eb89a44f9..71c8692487c9c1c5b956b4356501d523 net.minecraft.server.MinecraftServer.getServer().execute(() -> { runSync(player, bukkit, rootcommandnode); }); -@@ -495,6 +496,7 @@ public class Commands { +@@ -499,6 +500,7 @@ public class Commands { private void runSync(ServerPlayer player, Collection<String> bukkit, RootCommandNode<SharedSuggestionProvider> rootcommandnode) { // Paper end - Perf: Async command map building @@ -106,7 +106,7 @@ index 938db2436e0f099432263aba593e684eb89a44f9..71c8692487c9c1c5b956b4356501d523 PlayerCommandSendEvent event = new PlayerCommandSendEvent(player.getBukkitEntity(), new LinkedHashSet<>(bukkit)); event.getPlayer().getServer().getPluginManager().callEvent(event); -@@ -515,6 +517,11 @@ public class Commands { +@@ -519,6 +521,11 @@ public class Commands { while (iterator.hasNext()) { CommandNode<CommandSourceStack> commandnode2 = (CommandNode) iterator.next(); diff --git a/patches/server/0953-Brigadier-based-command-API.patch b/patches/server/0953-Brigadier-based-command-API.patch index 30feff2e13..0d56637cc8 100644 --- a/patches/server/0953-Brigadier-based-command-API.patch +++ b/patches/server/0953-Brigadier-based-command-API.patch @@ -2068,7 +2068,7 @@ index fc0c60b22844ed010aede2fa125b9fa440d3de80..3549ffea451b932602efb113844ba21a public org.bukkit.command.CommandSender getBukkitSender() { return this.source.getBukkitSender(this); diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java -index f190a65ee2e091d4d5a1e114178eac42740075d4..622677fb281242681bf8ba39de34187bcc898a5f 100644 +index cfa328f06c1b972c8328ff40580b485c02e0c270..62704cbfe3a232809b3e62d1f1d8beb3bea6496e 100644 --- a/src/main/java/net/minecraft/commands/Commands.java +++ b/src/main/java/net/minecraft/commands/Commands.java @@ -159,7 +159,7 @@ public class Commands { @@ -2135,7 +2135,7 @@ index f190a65ee2e091d4d5a1e114178eac42740075d4..622677fb281242681bf8ba39de34187b StackTraceElement[] astacktraceelement = exception.getStackTrace(); for (int i = 0; i < Math.min(astacktraceelement.length, 3); ++i) { -@@ -475,13 +494,7 @@ public class Commands { +@@ -479,13 +498,7 @@ public class Commands { private void sendAsync(ServerPlayer player, Collection<CommandNode<CommandSourceStack>> dispatcherRootChildren) { // Paper end - Perf: Async command map building Map<CommandNode<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> map = Maps.newIdentityHashMap(); // Use identity to prevent aliasing issues @@ -2150,7 +2150,7 @@ index f190a65ee2e091d4d5a1e114178eac42740075d4..622677fb281242681bf8ba39de34187b RootCommandNode<SharedSuggestionProvider> rootcommandnode = new RootCommandNode(); map.put(this.dispatcher.getRoot(), rootcommandnode); -@@ -516,6 +529,7 @@ public class Commands { +@@ -520,6 +533,7 @@ public class Commands { // Paper start - Perf: Async command map building; pass copy of children private void fillUsableCommands(Collection<CommandNode<CommandSourceStack>> children, CommandNode<SharedSuggestionProvider> result, CommandSourceStack source, Map<CommandNode<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> resultNodes) { @@ -2158,7 +2158,7 @@ index f190a65ee2e091d4d5a1e114178eac42740075d4..622677fb281242681bf8ba39de34187b Iterator iterator = children.iterator(); // Paper end - Perf: Async command map building -@@ -530,6 +544,42 @@ public class Commands { +@@ -534,6 +548,42 @@ public class Commands { if (commandnode2.canUse(source)) { ArgumentBuilder argumentbuilder = commandnode2.createBuilder(); // CraftBukkit - decompile error diff --git a/patches/server/0985-Fix-entity-type-tags-suggestions-in-selectors.patch b/patches/server/0985-Fix-entity-type-tags-suggestions-in-selectors.patch index 61b8db9955..826ee39209 100644 --- a/patches/server/0985-Fix-entity-type-tags-suggestions-in-selectors.patch +++ b/patches/server/0985-Fix-entity-type-tags-suggestions-in-selectors.patch @@ -37,10 +37,10 @@ index 3549ffea451b932602efb113844ba21a7bc72371..13bd145b1e8006a53c22f5dc0c78f29b + // Paper end - tell clients to ask server for suggestions for EntityArguments } diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java -index 622677fb281242681bf8ba39de34187bcc898a5f..daca005854ae2bb68300b19bceedadcbbe1e06fd 100644 +index 62704cbfe3a232809b3e62d1f1d8beb3bea6496e..2daf16ae4a30fe03bc1a1bbc3eb95b3b7bcd83fa 100644 --- a/src/main/java/net/minecraft/commands/Commands.java +++ b/src/main/java/net/minecraft/commands/Commands.java -@@ -533,6 +533,7 @@ public class Commands { +@@ -537,6 +537,7 @@ public class Commands { Iterator iterator = children.iterator(); // Paper end - Perf: Async command map building @@ -48,7 +48,7 @@ index 622677fb281242681bf8ba39de34187bcc898a5f..daca005854ae2bb68300b19bceedadcb while (iterator.hasNext()) { CommandNode<CommandSourceStack> commandnode2 = (CommandNode) iterator.next(); // Paper start - Brigadier API -@@ -595,6 +596,12 @@ public class Commands { +@@ -599,6 +600,12 @@ public class Commands { if (requiredargumentbuilder.getSuggestionsProvider() != null) { requiredargumentbuilder.suggests(SuggestionProviders.safelySwap(requiredargumentbuilder.getSuggestionsProvider())); |