mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-12-02 07:33:39 +01:00
c09ee99f7e
Closes #257 Ports 2 patches from Purpur: Infinity-bow-settings & Allow-infinite-and-mending-enchantments-together Added an option for infinity with no arrows too. Option for custom locale has come! You can put a locale.json file in your server folder to change it. We've got the finest patches from Hydrinity ( Mykyta approved & allowed ) too. We have some amazing new options in yatopia.yml, we're gonna have documentation for them soon so stay tuned! Last but not least, chunk generation patches. We've tested them extensively so no weirdness happens. Thanks for using Yatopia as your production server software. Co-authored-by: Ivan Pekov <ivan@mrivanplays.com>
77 lines
3.1 KiB
Diff
77 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 5df6be7e8d9b1295ed0700b3be90c3778fc7d77c..cbc03b8bc34e244c08a85bfd681707a49d1046f9 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()) bl(); // 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,16 @@ public abstract class IAsyncTaskHandler<R extends Runnable> implements Mailbox<R
|
|
}
|
|
|
|
protected void bl() {
|
|
+ // 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) {
|