Use CLQ for main thread tasks.

Means netty threads aren't blocked for long synchronisations whilst tasks are running.
This commit is contained in:
md_5 2015-04-19 20:20:50 +10:00 committed by Zach Brown
parent 6c710c1692
commit cf6a7ce46d
13 changed files with 99 additions and 43 deletions

View File

@ -1,4 +1,4 @@
From 00b24e2eea1e526a6d351ae508f66f9e5f71d474 Mon Sep 17 00:00:00 2001
From 2b98747833a588469352c523a5b5dd56ddf789b7 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 10 Jan 2013 00:18:11 -0500
Subject: [PATCH] Spigot Timings
@ -367,10 +367,10 @@ index 611a623..af2e9bc 100644
this.methodProfiler.b();
}
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 459752b..d6f6291 100644
index a295e61..eb977e1 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -1061,6 +1061,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
@@ -1067,6 +1067,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
// CraftBukkit end
private void handleCommand(String s) {
@ -378,7 +378,7 @@ index 459752b..d6f6291 100644
// CraftBukkit start - whole method
this.c.info(this.player.getName() + " issued server command: " + s);
@@ -1070,18 +1071,22 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
@@ -1076,18 +1077,22 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
this.server.getPluginManager().callEvent(event);
if (event.isCancelled()) {

View File

@ -1,14 +1,14 @@
From d18bd3032e8271601709a7c841c72716cfc6f624 Mon Sep 17 00:00:00 2001
From ab69bfc5ab7eaa0ef4fb1f568a2b0d88181d122d Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Fri, 21 Jun 2013 18:01:29 +1000
Subject: [PATCH] Allow Disabling of Command Logging
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index d6f6291..5b1900a 100644
index eb977e1..8e18c9f 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -1063,6 +1063,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
@@ -1069,6 +1069,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
private void handleCommand(String s) {
org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.startTiming(); // Spigot
// CraftBukkit start - whole method

View File

@ -1,14 +1,14 @@
From 38cd29103c2ced5c7da0603821c4f75d47960f42 Mon Sep 17 00:00:00 2001
From d4e1a324eb84acc9fc1b3e967292ee784beae6bf Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Fri, 28 Jun 2013 19:52:54 +1000
Subject: [PATCH] Disallow Interaction With Self
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 5b1900a..60fa768 100644
index 8e18c9f..2786399 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -1198,6 +1198,13 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
@@ -1204,6 +1204,13 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.u());
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
Entity entity = packetplayinuseentity.a((World) worldserver);

View File

@ -1,11 +1,11 @@
From 3044bd3231f451f14810c8382a6bac82b877d1b7 Mon Sep 17 00:00:00 2001
From ea79c836f34f613e75e1d40a5359210125ab3ae0 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sun, 6 Oct 2013 17:36:28 +1100
Subject: [PATCH] Don't Special Case X Move Value
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 60fa768..1e8dcc1 100644
index 2786399..a1341a7 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -109,6 +109,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
@ -16,7 +16,7 @@ index 60fa768..1e8dcc1 100644
public CraftPlayer getPlayer() {
return (this.player == null) ? null : (CraftPlayer) this.player.getBukkitEntity();
@@ -217,6 +218,18 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
@@ -223,6 +224,18 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
}
// CraftBukkit start - fire PlayerMoveEvent
Player player = this.getPlayer();
@ -35,7 +35,7 @@ index 60fa768..1e8dcc1 100644
Location from = new Location(player.getWorld(), lastPosX, lastPosY, lastPosZ, lastYaw, lastPitch); // Get the Players previous Event location.
Location to = player.getLocation().clone(); // Start off the To location as the Players current location.
@@ -245,7 +258,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
@@ -251,7 +264,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
this.lastPitch = to.getPitch();
// Skip the first time we do this

View File

@ -1,14 +1,14 @@
From eafea3420ac76bfdc51785764024dc8f74086cad Mon Sep 17 00:00:00 2001
From 19a15e7391ff2f82fce0fef0686aaec22364853d Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sat, 8 Feb 2014 08:13:40 +0000
Subject: [PATCH] Spam Filter Exclusions
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 1e8dcc1..63fe40e 100644
index a1341a7..788300c 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -969,9 +969,20 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
@@ -975,9 +975,20 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
this.minecraftServer.getPlayerList().sendMessage(chatmessage1, false);
}

View File

@ -1,14 +1,14 @@
From 62f6d3d586be6666187e97e5dcd38689dddf6567 Mon Sep 17 00:00:00 2001
From 1e6077f596837a4ae0328b6a179779f78a41d04f Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Wed, 12 Feb 2014 18:18:01 +1100
Subject: [PATCH] Allow Disabling Creative Item Filter
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 63fe40e..cf794b5 100644
index 788300c..78f6444 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -1695,7 +1695,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
@@ -1701,7 +1701,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() < 36 + PlayerInventory.getHotbarSize();
// CraftBukkit - Add invalidItems check

View File

@ -1,4 +1,4 @@
From b1bae6016141e328ccc661362d7cbba0833f3ab2 Mon Sep 17 00:00:00 2001
From 606b505960fd5b49dc45cc87a79e08a106ffc85f Mon Sep 17 00:00:00 2001
From: hcherndon <hcherndon@gmail.com>
Date: Sat, 15 Feb 2014 01:51:20 -0600
Subject: [PATCH] Unfinalize the isDisconnected() method by bukkit.
@ -6,10 +6,10 @@ Subject: [PATCH] Unfinalize the isDisconnected() method by bukkit.
This would literally mean the world to me. You have no idea how much this method being final is fucking me over right now. (Working with NPC's and what not.)
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index cf794b5..d8f9299 100644
index 78f6444..66366fc 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -2058,7 +2058,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
@@ -2064,7 +2064,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
}
// CraftBukkit start - Add "isDisconnected" method

View File

@ -1,4 +1,4 @@
From 4c5b325c337e4824aadd558eb5dc9321481fb3d6 Mon Sep 17 00:00:00 2001
From d9429048c292e4bcaa5409ea686274a6efd3b138 Mon Sep 17 00:00:00 2001
From: drXor <mcyoungsota@gmail.com>
Date: Sat, 15 Mar 2014 01:30:05 -0400
Subject: [PATCH] Descriptive kick reasons instead of Nope!
@ -27,10 +27,10 @@ index 82accf4..d6bef0b 100644
f1 = 0;
}
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index d8f9299..8e8f1cf 100644
index 66366fc..fbab12e 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -194,7 +194,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
@@ -200,7 +200,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
|| !NumberConversions.isFinite(packetplayinflying.yaw)
|| !NumberConversions.isFinite(packetplayinflying.pitch)) {
c.warn(player.getName() + " was caught trying to crash the server with an invalid position.");
@ -39,7 +39,7 @@ index d8f9299..8e8f1cf 100644
return;
}
// CraftBukkit end
@@ -892,7 +892,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
@@ -898,7 +898,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
this.player.z();
} else {
PlayerConnection.c.warn(this.player.getName() + " tried to set an invalid carried item");

View File

@ -1,4 +1,4 @@
From a4f10950a712aa45be78dc52b0649bd0840bed42 Mon Sep 17 00:00:00 2001
From e323209d6bb5583e741a3573d8b1993a19d740ef Mon Sep 17 00:00:00 2001
From: riking <rikingcoding@gmail.com>
Date: Wed, 14 May 2014 13:46:48 -0700
Subject: [PATCH] Process conversation input on the main thread. Fixes
@ -6,10 +6,10 @@ Subject: [PATCH] Process conversation input on the main thread. Fixes
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 8e8f1cf..188e6ce 100644
index fbab12e..c46e943 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -954,7 +954,18 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
@@ -960,7 +960,18 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
} else if (s.isEmpty()) {
c.warn(this.player.getName() + " tried to send an empty message");
} else if (getPlayer().isConversing()) {

View File

@ -1,4 +1,4 @@
From 84ab4d1c872c790b2dd1c43afbd2a429dbd76f89 Mon Sep 17 00:00:00 2001
From 4d08e72d67e499a79d97a6702f8db54fe287496e Mon Sep 17 00:00:00 2001
From: Thinkofdeath <thinkofdeath@spigotmc.org>
Date: Sun, 29 Jun 2014 21:10:34 +0100
Subject: [PATCH] Limit block placement/interaction packets
@ -24,10 +24,10 @@ index c611db1..28cb5e3 100644
public void b(PacketDataSerializer packetdataserializer) throws IOException {}
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 188e6ce..9ea05bd 100644
index c46e943..b64503d 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -626,10 +626,23 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
@@ -632,10 +632,23 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
// CraftBukkit end
}
@ -52,7 +52,7 @@ index 188e6ce..9ea05bd 100644
// CraftBukkit start
if (this.player.dead) return;
@@ -652,7 +665,8 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
@@ -658,7 +671,8 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
// CraftBukkit start
int itemstackAmount = itemstack.count;
@ -62,7 +62,7 @@ index 188e6ce..9ea05bd 100644
// Raytrace to look for 'rogue armswings'
float f1 = this.player.pitch;
float f2 = this.player.yaw;
@@ -688,6 +702,8 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
@@ -694,6 +708,8 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
if (!cancelled) {
this.player.playerInteractManager.useItem(this.player, this.player.world, itemstack);
}
@ -71,7 +71,7 @@ index 188e6ce..9ea05bd 100644
// CraftBukkit - notch decrements the counter by 1 in the above method with food,
// snowballs and so forth, but he does it in a place that doesn't cause the
@@ -713,7 +729,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
@@ -719,7 +735,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
}
if (this.checkMovement && this.player.e((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && !this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) {
@ -80,7 +80,7 @@ index 188e6ce..9ea05bd 100644
}
flag = true;
@@ -1130,6 +1146,19 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
@@ -1136,6 +1152,19 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
public void a(PacketPlayInArmAnimation packetplayinarmanimation) {
if (this.player.dead) return; // CraftBukkit
PlayerConnectionUtils.ensureMainThread(packetplayinarmanimation, this, this.player.u());

View File

@ -1,14 +1,14 @@
From d56ab7af0599afc6674b4825f22cab3cda051ad4 Mon Sep 17 00:00:00 2001
From 6f7f9b857c6586787dd57c3488142aada77d97a2 Mon Sep 17 00:00:00 2001
From: Jonas Konrad <me@yawk.at>
Date: Fri, 4 Jul 2014 23:03:13 +0200
Subject: [PATCH] Make "moved wrongly" limit configurable
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 9ea05bd..056516c 100644
index b64503d..44c8052 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -416,7 +416,8 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
@@ -422,7 +422,8 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
d17 = d11 * d11 + d12 * d12 + d13 * d13;
boolean flag1 = false;

View File

@ -1,14 +1,14 @@
From 9c6f37051dbfb75d73f01f7437d14e125b300ccd Mon Sep 17 00:00:00 2001
From d9bdd343cac4ba10519ebb8ec29a2f6db33182f2 Mon Sep 17 00:00:00 2001
From: Jonas Konrad <me@yawk.at>
Date: Tue, 22 Jul 2014 15:59:01 +0200
Subject: [PATCH] Make "moved too quickly" limit configurable
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 056516c..5f3884a 100644
index 44c8052..3108938 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -389,7 +389,8 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
@@ -395,7 +395,8 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
// CraftBukkit end
double d17 = d14 * d14 + d15 * d15 + d16 * d16;

View File

@ -0,0 +1,56 @@
From f7dee00c85a3c65a1132e1aa3f8a5aac417ba887 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Sun, 19 Apr 2015 09:19:39 +1000
Subject: [PATCH] Use CLQ for main thread tasks.
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 88640a5..1aa659d 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -104,7 +104,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
private long X = 0L;
private final GameProfileRepository Y;
private final UserCache Z;
- protected final Queue<FutureTask<?>> j = Queues.newArrayDeque();
+ protected final Queue<FutureTask<?>> j = new java.util.concurrent.ConcurrentLinkedQueue<FutureTask<?>>(); // Spigot, PAIL: Rename
private Thread serverThread;
private long ab = ay();
@@ -705,11 +705,13 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
this.methodProfiler.a("jobs");
Queue queue = this.j;
- synchronized (this.j) {
- while (!this.j.isEmpty()) {
- SystemUtils.a((FutureTask) this.j.poll(), MinecraftServer.LOGGER);
- }
- }
+ // Spigot start
+ FutureTask<?> entry;
+ int count = this.j.size();
+ while ((entry = this.j.poll()) != null && count-- > 0) {
+ SystemUtils.a(entry, MinecraftServer.LOGGER);
+ }
+ // Spigot end
this.methodProfiler.c("levels");
@@ -1493,10 +1495,10 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
ListenableFutureTask listenablefuturetask = ListenableFutureTask.create(callable);
Queue queue = this.j;
- synchronized (this.j) {
- this.j.add(listenablefuturetask);
- return listenablefuturetask;
- }
+ // Spigot start
+ this.j.add(listenablefuturetask);
+ return listenablefuturetask;
+ // Spigot end
} else {
try {
return Futures.immediateFuture(callable.call());
--
2.1.0