Add a config to turn off Optimized TickList #3145

Set:

settings:
  - use-optimized-ticklist: false

If you are having issues with block updates and want to see if this fixes it.

Please report confirmations on #3145 ticket
This commit is contained in:
Aikar 2020-04-26 04:01:03 -04:00
parent d847d33684
commit 68994c64ec
No known key found for this signature in database
GPG Key ID: 401ADFC9891FAAFE
6 changed files with 78 additions and 42 deletions

View File

@ -1,4 +1,4 @@
From f9dbb955a21c698e64cda2fed7a3ae215d660d11 Mon Sep 17 00:00:00 2001
From d68c3922b8ad5380a018e2302e703d9066c659c5 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Fri, 14 Feb 2020 01:24:39 -0800
Subject: [PATCH] Optimise TickListServer by rewriting it
@ -41,6 +41,24 @@ and -Dpaper.ticklist-excessive-delay-threshold=ticks which
sets the excessive tick delay to the specified ticks (defaults to
60 * 20 ticks, aka 60 seconds)
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index f4836e2da1..647f6fc8ef 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -369,6 +369,13 @@ public class PaperConfig {
maxBookTotalSizeMultiplier = getDouble("settings.book-size.total-multiplier", maxBookTotalSizeMultiplier);
}
+ public static boolean useOptimizedTickList = true;
+ private static void useOptimizedTickList() {
+ if (config.contains("settings.use-optimized-ticklist")) { // don't add default, hopefully temporary config
+ useOptimizedTickList = config.getBoolean("settings.use-optimized-ticklist");
+ }
+ }
+
public static boolean asyncChunks = false;
private static void asyncChunks() {
ConfigurationSection section;
diff --git a/src/main/java/com/destroystokyo/paper/server/ticklist/PaperTickList.java b/src/main/java/com/destroystokyo/paper/server/ticklist/PaperTickList.java
new file mode 100644
index 0000000000..ce653f6b4b
@ -877,7 +895,7 @@ index e650a2e48d..2d07d350d2 100644
return this.b(baseblockposition.getX(), baseblockposition.getY(), baseblockposition.getZ());
}
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 57e797cd86..2e63f64783 100644
index e67e006535..ca1b5b3b09 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -200,6 +200,13 @@ public class ChunkProviderServer extends IChunkProvider {
@ -1143,36 +1161,54 @@ index f533860bbe..3f1aa5ced6 100644
}
}
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 95860454da..b74f701b9e 100644
index 9a2b4fa7a2..9b9e242432 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -170,6 +170,13 @@ public class WorldServer extends World {
@@ -170,6 +170,15 @@ public class WorldServer extends World {
}
// Paper end
+ // Paper start - rewrite ticklistserver
+ void onChunkSetTicking(int chunkX, int chunkZ) {
+ ((com.destroystokyo.paper.server.ticklist.PaperTickList)this.nextTickListBlock).onChunkSetTicking(chunkX, chunkZ);
+ ((com.destroystokyo.paper.server.ticklist.PaperTickList)this.nextTickListFluid).onChunkSetTicking(chunkX, chunkZ);
+ if (com.destroystokyo.paper.PaperConfig.useOptimizedTickList) {
+ ((com.destroystokyo.paper.server.ticklist.PaperTickList) this.nextTickListBlock).onChunkSetTicking(chunkX, chunkZ);
+ ((com.destroystokyo.paper.server.ticklist.PaperTickList) this.nextTickListFluid).onChunkSetTicking(chunkX, chunkZ);
+ }
+ }
+ // Paper end - rewrite ticklistserver
+
// Add env and gen to constructor
public WorldServer(MinecraftServer minecraftserver, Executor executor, WorldNBTStorage worldnbtstorage, WorldData worlddata, DimensionManager dimensionmanager, GameProfilerFiller gameprofilerfiller, WorldLoadListener worldloadlistener, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen) {
super(worlddata, dimensionmanager, (world, worldprovider) -> {
@@ -190,10 +197,10 @@ public class WorldServer extends World {
@@ -190,12 +199,22 @@ public class WorldServer extends World {
this.pvpMode = minecraftserver.getPVP();
worlddata.world = this;
// CraftBukkit end
- this.nextTickListBlock = new TickListServer<>(this, (block) -> {
+ this.nextTickListBlock = new com.destroystokyo.paper.server.ticklist.PaperTickList<>(this, (block) -> { // Paper - optimise TickListServer
return block == null || block.getBlockData().isAir();
}, IRegistry.BLOCK::getKey, IRegistry.BLOCK::get, this::b, "Blocks"); // Paper - Timings
- return block == null || block.getBlockData().isAir();
- }, IRegistry.BLOCK::getKey, IRegistry.BLOCK::get, this::b, "Blocks"); // Paper - Timings
- this.nextTickListFluid = new TickListServer<>(this, (fluidtype) -> {
+ this.nextTickListFluid = new com.destroystokyo.paper.server.ticklist.PaperTickList<>(this, (fluidtype) -> { // Paper - optimise TickListServer
return fluidtype == null || fluidtype == FluidTypes.EMPTY;
}, IRegistry.FLUID::getKey, IRegistry.FLUID::get, this::a, "Fluids"); // Paper - Timings
- return fluidtype == null || fluidtype == FluidTypes.EMPTY;
- }, IRegistry.FLUID::getKey, IRegistry.FLUID::get, this::a, "Fluids"); // Paper - Timings
+ if (com.destroystokyo.paper.PaperConfig.useOptimizedTickList) {
+ this.nextTickListBlock = new com.destroystokyo.paper.server.ticklist.PaperTickList<>(this, (block) -> { // Paper - optimise TickListServer
+ return block == null || block.getBlockData().isAir();
+ }, IRegistry.BLOCK::getKey, IRegistry.BLOCK::get, this::b, "Blocks"); // Paper - Timings
+ this.nextTickListFluid = new com.destroystokyo.paper.server.ticklist.PaperTickList<>(this, (fluidtype) -> { // Paper - optimise TickListServer
+ return fluidtype == null || fluidtype == FluidTypes.EMPTY;
+ }, IRegistry.FLUID::getKey, IRegistry.FLUID::get, this::a, "Fluids"); // Paper - Timings
+ } else {
+ this.nextTickListBlock = new TickListServer<>(this, (block) -> { // Paper - optimise TickListServer
+ return block == null || block.getBlockData().isAir();
+ }, IRegistry.BLOCK::getKey, IRegistry.BLOCK::get, this::b, "Blocks"); // Paper - Timings
+ this.nextTickListFluid = new TickListServer<>(this, (fluidtype) -> { // Paper - optimise TickListServer
+ return fluidtype == null || fluidtype == FluidTypes.EMPTY;
+ }, IRegistry.FLUID::getKey, IRegistry.FLUID::get, this::a, "Fluids"); // Paper - Timings
+ }
+
this.navigators = Sets.newHashSet();
this.I = new ObjectLinkedOpenHashSet();
this.dataManager = worldnbtstorage;
--
2.25.1
2.26.2

View File

@ -1,4 +1,4 @@
From 45ecc86e6bc96656bd8fc6509032739dac6978f6 Mon Sep 17 00:00:00 2001
From 175903c5f46c71f254704cc6bd336d6b965da427 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 29 Mar 2020 18:26:14 -0400
Subject: [PATCH] Ensure Entity is never double registered
@ -23,10 +23,10 @@ index 16f2e32d23..9cb4e5a1e6 100644
private boolean locked = false;
@Override
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index de24b487d2..e198b8c565 100644
index 9b9e242432..f80c80957a 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -520,6 +520,7 @@ public class WorldServer extends World {
@@ -532,6 +532,7 @@ public class WorldServer extends World {
try (co.aikar.timings.Timing ignored = this.timings.newEntities.startTiming()) { // Paper - timings
while ((entity = (Entity) this.entitiesToAdd.poll()) != null) {
@ -34,7 +34,7 @@ index de24b487d2..e198b8c565 100644
this.registerEntity(entity);
}
} // Paper - timings
@@ -1342,6 +1343,19 @@ public class WorldServer extends World {
@@ -1354,6 +1355,19 @@ public class WorldServer extends World {
public void unregisterEntity(Entity entity) {
org.spigotmc.AsyncCatcher.catchOp("entity unregister"); // Spigot
@ -54,7 +54,7 @@ index de24b487d2..e198b8c565 100644
// Spigot start
if ( entity instanceof EntityHuman )
{
@@ -1403,9 +1417,21 @@ public class WorldServer extends World {
@@ -1415,9 +1429,21 @@ public class WorldServer extends World {
private void registerEntity(Entity entity) {
org.spigotmc.AsyncCatcher.catchOp("entity register"); // Spigot
@ -78,5 +78,5 @@ index de24b487d2..e198b8c565 100644
if (entity instanceof EntityEnderDragon) {
EntityComplexPart[] aentitycomplexpart = ((EntityEnderDragon) entity).eo();
--
2.25.1
2.26.2

View File

@ -1,4 +1,4 @@
From 3b90bd5d0498f4f789321cae8e45861b623847a3 Mon Sep 17 00:00:00 2001
From a0515596981b6463ee95682428a6934643eee6b1 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 31 Mar 2020 03:01:45 -0400
Subject: [PATCH] Fix unregistering entities from unloading chunks
@ -15,10 +15,10 @@ Combine that with a buggy detail of the previous implementation of
the Dupe UUID patch, then this was the likely source of the "Ghost entities"
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index e198b8c565..b3e1e3686b 100644
index f80c80957a..3f8f40018d 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -1496,9 +1496,9 @@ public class WorldServer extends World {
@@ -1508,9 +1508,9 @@ public class WorldServer extends World {
}
private void removeEntityFromChunk(Entity entity) {
@ -31,5 +31,5 @@ index e198b8c565..b3e1e3686b 100644
}
--
2.25.1
2.26.2

View File

@ -1,4 +1,4 @@
From 6a1574bd21ab6847006a7442f92ec0d6ec49e974 Mon Sep 17 00:00:00 2001
From 3ecc6bbeefb3fa6add163a675c12416c393797e8 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 2 Apr 2020 01:42:39 -0400
Subject: [PATCH] Prevent Double PlayerChunkMap adds crashing server
@ -7,7 +7,7 @@ Suspected case would be around the technique used in .stopRiding
Stack will identify any causer of this and warn instead of crashing.
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index f570c40496..be75b9dd14 100644
index 7e7d7308f2..a61510c944 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -1489,6 +1489,14 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@ -26,10 +26,10 @@ index f570c40496..be75b9dd14 100644
if (!(entity instanceof EntityLightning)) {
EntityTypes<?> entitytypes = entity.getEntityType();
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index b3e1e3686b..142770bcd6 100644
index 3f8f40018d..532aba2a5d 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -1462,7 +1462,7 @@ public class WorldServer extends World {
@@ -1474,7 +1474,7 @@ public class WorldServer extends World {
}
}
@ -38,7 +38,7 @@ index b3e1e3686b..142770bcd6 100644
// CraftBukkit start - SPIGOT-5278
if (entity instanceof EntityDrowned) {
this.navigators.add(((EntityDrowned) entity).navigationWater);
@@ -1473,6 +1473,7 @@ public class WorldServer extends World {
@@ -1485,6 +1485,7 @@ public class WorldServer extends World {
this.navigators.add(((EntityInsentient) entity).getNavigation());
}
entity.valid = true; // CraftBukkit

View File

@ -1,4 +1,4 @@
From 815a77a6e4431669b2b8bc9d1fefd5735403d6c5 Mon Sep 17 00:00:00 2001
From 14f957b43c0b434dabc2bd03da4f19285e11eccd Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 9 Apr 2020 00:09:26 -0400
Subject: [PATCH] Mid Tick Chunk Tasks - Speed up processing of chunk loads and
@ -42,10 +42,10 @@ index 223d3b1125..37341d2d2e 100644
public static final Timing commandFunctionsTimer = Timings.ofSafe("Command Functions");
public static final Timing connectionTimer = Timings.ofSafe("Connection Handler");
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index f4836e2da1..a6107ba016 100644
index 647f6fc8ef..9f1662ece5 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -414,4 +414,9 @@ public class PaperConfig {
@@ -421,4 +421,9 @@ public class PaperConfig {
log("Async Chunks: Enabled - Chunks will be loaded much faster, without lag.");
}
}
@ -226,10 +226,10 @@ index 77adc64e30..3c25436f15 100644
// Spigot Start
CrashReport crashreport;
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 142770bcd6..3f62fe2bb1 100644
index 532aba2a5d..dc01fb494d 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -420,6 +420,7 @@ public class WorldServer extends World {
@@ -432,6 +432,7 @@ public class WorldServer extends World {
}
timings.scheduledBlocks.stopTiming(); // Spigot
@ -237,7 +237,7 @@ index 142770bcd6..3f62fe2bb1 100644
gameprofilerfiller.exitEnter("raid");
this.timings.raids.startTiming(); // Paper - timings
this.persistentRaid.a();
@@ -432,6 +433,7 @@ public class WorldServer extends World {
@@ -444,6 +445,7 @@ public class WorldServer extends World {
timings.doSounds.startTiming(); // Spigot
this.ad();
timings.doSounds.stopTiming(); // Spigot
@ -245,7 +245,7 @@ index 142770bcd6..3f62fe2bb1 100644
this.ticking = false;
gameprofilerfiller.exitEnter("entities");
boolean flag3 = true || !this.players.isEmpty() || !this.getForceLoadedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players
@@ -517,6 +519,7 @@ public class WorldServer extends World {
@@ -529,6 +531,7 @@ public class WorldServer extends World {
timings.entityTick.stopTiming(); // Spigot
this.tickingEntities = false;
@ -253,7 +253,7 @@ index 142770bcd6..3f62fe2bb1 100644
try (co.aikar.timings.Timing ignored = this.timings.newEntities.startTiming()) { // Paper - timings
while ((entity = (Entity) this.entitiesToAdd.poll()) != null) {
@@ -527,6 +530,7 @@ public class WorldServer extends World {
@@ -539,6 +542,7 @@ public class WorldServer extends World {
gameprofilerfiller.exit();
timings.tickEntities.stopTiming(); // Spigot

View File

@ -1,4 +1,4 @@
From 958960ca7b7f0a32d86b5ace9f13002da7eede33 Mon Sep 17 00:00:00 2001
From 9c8a19c1cb2ef8705cca05c105227b3ae8cef0ea Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 11 Apr 2020 21:23:42 -0400
Subject: [PATCH] Delay unsafe actions until after entity ticking is done
@ -6,7 +6,7 @@ Subject: [PATCH] Delay unsafe actions until after entity ticking is done
This will help prevent many cases of unregistering entities during entity ticking
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 4b9b79a9..9e9a1b2a 100644
index dc01fb494d..d13dc8fce9 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -60,6 +60,16 @@ public class WorldServer extends World {
@ -26,7 +26,7 @@ index 4b9b79a9..9e9a1b2a 100644
private final MinecraftServer server;
private final WorldNBTStorage dataManager;
public boolean savingDisabled;
@@ -519,6 +529,16 @@ public class WorldServer extends World {
@@ -531,6 +541,16 @@ public class WorldServer extends World {
timings.entityTick.stopTiming(); // Spigot
this.tickingEntities = false;
@ -44,7 +44,7 @@ index 4b9b79a9..9e9a1b2a 100644
try (co.aikar.timings.Timing ignored = this.timings.newEntities.startTiming()) { // Paper - timings
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 1fbb1344..f56131e3 100644
index 1fbb1344fc..f56131e3a5 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -2469,7 +2469,7 @@ public class CraftWorld implements World {
@ -57,5 +57,5 @@ index 1fbb1344..f56131e3 100644
return ret;
--
2.25.1.windows.1
2.26.2