Yatopia/patches/server/0050-Improve-task-performance.patch
Ivan Pekov 7f24790a35
Updated Upstream and Sidestream(s) (Tuinity/EMC/Purpur/AirplaneLite)
Upstream/An Sidestream has released updates that appears to apply and compile correctly
This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing.

Tuinity Changes:
cf37529 Updated Upstream (Paper)

EMC Changes:
27282006 Updated Paper
456edfa4 One more try to fix more chunks on reload

Purpur Changes:
45d5e9a Fix dolphin spit and phantom flames
9e1b8e7 Clean up teleport outside border patch Add sleeping, inventory, and toWorld checks
8428580 [ci-skip] Add 'fast' argument to './purpur jar' to speed up jenkins build time
cea486c Updated Upstream (Paper)
6cd244c Fix infinite furnaces triggering without lava source
a989361 Fix infinite furnaces leaving empty buckets
6cf1672 Add config option for whether Nether Wart farming Villagers should throw extra Nether Warts at other Villagers
07d4056 Add toggle for Zombified Piglin death always counting as a player kill when angry (Zombified Piglin XP farm nerf option)
9935466 Add config option for Cleric Villagers to farm Nether Wart
47a1707 fix typos
6e42ce8 Updated Upstream (Paper)
740b7d2 [ci-skip] Update readme with downloads API info

AirplaneLite Changes:
5526dde Add download link to readme
2020-12-07 10:10:55 +02:00

78 lines
3.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: ishland <ishlandmc@yeah.net>
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
Co-authored-by: Mykyta Komarn <nkomarn@hotmail.com>
diff --git a/src/main/java/net/minecraft/server/IAsyncTaskHandler.java b/src/main/java/net/minecraft/server/IAsyncTaskHandler.java
index 27db247aa40e0516302c74b9bf00c631a8607af5..6f14c97fcc36c0717f72443d620c2383e102ba0f 100644
--- a/src/main/java/net/minecraft/server/IAsyncTaskHandler.java
+++ b/src/main/java/net/minecraft/server/IAsyncTaskHandler.java
@@ -13,9 +13,11 @@ public abstract class IAsyncTaskHandler<R extends Runnable> implements Mailbox<R
private final String b;
private static final Logger LOGGER = LogManager.getLogger();
- private final Queue<R> d = Queues.newConcurrentLinkedQueue();
+ private final java.util.concurrent.BlockingDeque<R> d = new java.util.concurrent.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 +81,7 @@ public abstract class IAsyncTaskHandler<R extends Runnable> implements Mailbox<R
public final void addTask(R r0) { a(r0); }; // Paper - OBFHELPER
public void a(R r0) {
this.d.add(r0);
- LockSupport.unpark(this.getThread());
+ // LockSupport.unpark(this.getThread()); // Yatopia - improve task performance - replaced by LinkedBlockingQueue
}
public void execute(Runnable runnable) {
@@ -99,14 +101,18 @@ public abstract class IAsyncTaskHandler<R extends Runnable> implements Mailbox<R
}
protected boolean executeNext() {
- R r0 = this.d.peek(); // Paper - decompile fix
+ if(next == null && !d.isEmpty()) bm(); // Yatopia - Improve task performance
- if (r0 == null) {
+ if (next == null) { // Yatopia - Improve task performance
return false;
- } else if (this.e == 0 && !this.canExecute(r0)) {
+ } else if (this.e == 0 && !this.canExecute(next)) { // Yatopia - Improve task performance
return false;
} else {
- this.executeTask(this.d.remove()); // Paper - decompile fix
+ // Yatopia start - Improve task performance
+ R r = next;
+ next = null;
+ this.executeTask(r); // Paper - decompile fix
+ // Yatopia end
return true;
}
}
@@ -127,8 +133,17 @@ public abstract class IAsyncTaskHandler<R extends Runnable> implements Mailbox<R
}
protected void bm() {
+ // Yatopia start - replaced logic
+ /*
Thread.yield();
LockSupport.parkNanos("waiting for tasks", 100000L);
+ */
+ next = null;
+ try {
+ next = d.poll(100, java.util.concurrent.TimeUnit.MICROSECONDS);
+ } catch (InterruptedException ignored) {
+ }
+ // Yatopia end
}
protected void executeTask(R r0) {