diff --git a/PATCHES.md b/PATCHES.md index 6bb45f14..5ea8a430 100644 --- a/PATCHES.md +++ b/PATCHES.md @@ -64,7 +64,7 @@ # Patches | server | Implement bed explosion options | William Blake Galbreath | | | server | Implement respawn anchor explosion options | William Blake Galbreath | | | server | Improve Hopper Performance | Aikar | | -| server | Improve async task handler | ishland | | +| server | Improve task performance | ishland | | | server | Item stuck sleep config | tr7zw | | | api | Kill AnnotationTest | tr7zw | | | server | Lagging threshold | William Blake Galbreath | | diff --git a/patches/server/0050-Improve-async-task-handler.patch b/patches/server/0050-Improve-async-task-handler.patch deleted file mode 100644 index ebb87309..00000000 --- a/patches/server/0050-Improve-async-task-handler.patch +++ /dev/null @@ -1,82 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: ishland -Date: Sun, 20 Sep 2020 19:43:03 +0300 -Subject: [PATCH] Improve async task handler - -Replace ConcurrentLinkedQueue and LockSupport hacks to reduce execute times - -diff --git a/src/main/java/net/minecraft/server/IAsyncTaskHandler.java b/src/main/java/net/minecraft/server/IAsyncTaskHandler.java -index 5df6be7e8d9b1295ed0700b3be90c3778fc7d77c..95aec7d4705a7a275fe7f5d6aec877dd7ad0f529 100644 ---- a/src/main/java/net/minecraft/server/IAsyncTaskHandler.java -+++ b/src/main/java/net/minecraft/server/IAsyncTaskHandler.java -@@ -13,8 +13,9 @@ public abstract class IAsyncTaskHandler implements Mailbox d = Queues.newConcurrentLinkedQueue(); -+ private final java.util.concurrent.LinkedBlockingDeque d = new java.util.concurrent.LinkedBlockingDeque<>(); // Yatopia - private int e; -+ private R next = null; // Yatopia - - protected IAsyncTaskHandler(String s) { - this.b = s; -@@ -79,7 +80,7 @@ public abstract class IAsyncTaskHandler implements Mailbox implements Mailbox public -+ /* // Yatopia start - replaced logic - while (this.executeNext()) { - ; - } -+ */ -+ while (!d.isEmpty()) { -+ if (next == null) queuePull(); -+ if (!executeNext()) break; -+ } -+ // Yatopia end - - } - - protected boolean executeNext() { -- R r0 = this.d.peek(); // Paper - decompile fix -+ R r0 = next; // Paper - decompile fix // Yatopia - temp storage -+ if (next == null || !d.isEmpty()) queuePull(); // Yatopia - attempt to get from queue - - if (r0 == null) { - return false; - } else if (this.e == 0 && !this.canExecute(r0)) { - return false; - } else { -- this.executeTask(this.d.remove()); // Paper - decompile fix -+ this.executeTask(r0); // Paper - decompile fix // Yatopia - replaced with r0 -+ next = null; // Yatopia - clear temp for next task - return true; - } - } -@@ -126,9 +136,17 @@ public abstract class IAsyncTaskHandler implements Mailbox +Date: Sun, 20 Sep 2020 00:05:44 +0800 +Subject: [PATCH] Improve task performance + +Replace ConcurrentLinkedQueue + LockSupport hack to reduce time +consumption of addTask(R)V + +diff --git a/src/main/java/net/minecraft/server/IAsyncTaskHandler.java b/src/main/java/net/minecraft/server/IAsyncTaskHandler.java +index 5df6be7e8d9b1295ed0700b3be90c3778fc7d77c..7910d95bdd42ed97a5cab75c0da5bdacf030b92f 100644 +--- a/src/main/java/net/minecraft/server/IAsyncTaskHandler.java ++++ b/src/main/java/net/minecraft/server/IAsyncTaskHandler.java +@@ -1,11 +1,12 @@ + package net.minecraft.server; + + import com.google.common.collect.Queues; ++ + import java.util.Queue; +-import java.util.concurrent.CompletableFuture; +-import java.util.concurrent.Executor; ++import java.util.concurrent.*; + import java.util.concurrent.locks.LockSupport; + import java.util.function.BooleanSupplier; ++ + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; + +@@ -13,9 +14,11 @@ public abstract class IAsyncTaskHandler implements Mailbox d = Queues.newConcurrentLinkedQueue(); ++ private final LinkedBlockingDeque d = new LinkedBlockingDeque<>(); // Yatopia - improve task performance + private int e; + ++ private R next = null; // Yatopia - improve task performance - temp storage for next object ++ + protected IAsyncTaskHandler(String s) { + this.b = s; + } +@@ -79,7 +82,7 @@ public abstract class IAsyncTaskHandler implements Mailbox implements Mailbox public +- while (this.executeNext()) { +- ; ++ // Yatopia start - replaced logic ++ while (!d.isEmpty()) { ++ if(next == null) bl(); ++ if(!executeNext()) break; + } ++ // Yatopia end + + } + + protected boolean executeNext() { +- R r0 = this.d.peek(); // Paper - decompile fix ++ R r0 = next; // Paper - decompile fix // Yatopia - replaced with temp storage ++ ++ if(next == null && !d.isEmpty()) bl(); // Yatopia - attempt to get from queue + + if (r0 == null) { + return false; + } else if (this.e == 0 && !this.canExecute(r0)) { + return false; + } else { +- this.executeTask(this.d.remove()); // Paper - decompile fix ++ this.executeTask(r0); // Paper - decompile fix // Yatopia - replaced with current r0 ++ next = null; // Yatopia - clear storage for next task + return true; + } + } +@@ -127,8 +136,13 @@ public abstract class IAsyncTaskHandler implements Mailbox