Add more timings to chunk provider tick (#2549)

- Misc mob spawning
- Chunk range checks
This commit is contained in:
Spottedleaf 2019-09-29 14:06:03 -07:00 committed by Zach
parent 43ec79a32c
commit d39916c7e2
3 changed files with 71 additions and 34 deletions

View file

@ -1,4 +1,4 @@
From 0c34b70f8d3e5b2d85148ffae2ee45dd4f77763f Mon Sep 17 00:00:00 2001
From be74ac3e69b0d150492e1ae410e76b8a5ba5914b Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 3 Mar 2016 04:00:11 -0600
Subject: [PATCH] Timings v2
@ -147,10 +147,10 @@ index 0000000000..c6818bc86a
+}
diff --git a/src/main/java/co/aikar/timings/WorldTimingsHandler.java b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
new file mode 100644
index 0000000000..92c32c48d2
index 0000000000..3a79cde595
--- /dev/null
+++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
@@ -0,0 +1,120 @@
@@ -0,0 +1,130 @@
+package co.aikar.timings;
+
+import net.minecraft.server.World;
@ -211,6 +211,11 @@ index 0000000000..92c32c48d2
+ public final Timing worldSaveLevel;
+ public final Timing chunkSaveData;
+
+
+ public final Timing miscMobSpawning;
+ public final Timing chunkRangeCheckBig;
+ public final Timing chunkRangeCheckSmall;
+
+ public WorldTimingsHandler(World server) {
+ String name = server.worldData.getName() +" - ";
+
@ -265,6 +270,11 @@ index 0000000000..92c32c48d2
+ chunkProviderTick = Timings.ofSafe(name + "Chunk provider tick");
+ broadcastChunkUpdates = Timings.ofSafe(name + "Broadcast chunk updates");
+ countNaturalMobs = Timings.ofSafe(name + "Count natural mobs");
+
+
+ miscMobSpawning = Timings.ofSafe(name + "Mob spawning - Misc");
+ chunkRangeCheckBig = Timings.ofSafe(name + "Chunk Tick Range - Big");
+ chunkRangeCheckSmall = Timings.ofSafe(name + "Chunk Tick Range - Small");
+ }
+
+ public static Timing getTickList(WorldServer worldserver, String timingsType) {
@ -359,7 +369,7 @@ index 3ed48be382..c4d989f702 100644
}
}
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 3b785a3ade..e51e3b74cc 100644
index 3b785a3ade..15480a8dfb 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -129,11 +129,13 @@ public class ChunkProviderServer extends IChunkProvider {
@ -411,7 +421,7 @@ index 3b785a3ade..e51e3b74cc 100644
this.world.getMethodProfiler().exit();
this.playerChunkMap.f().forEach((playerchunk) -> {
Optional<Chunk> optional = ((Either) playerchunk.b().getNow(PlayerChunk.UNLOADED_CHUNK)).left();
@@ -399,7 +407,9 @@ public class ChunkProviderServer extends IChunkProvider {
@@ -399,13 +407,27 @@ public class ChunkProviderServer extends IChunkProvider {
Chunk chunk = (Chunk) optional.get();
this.world.getMethodProfiler().enter("broadcast");
@ -421,7 +431,27 @@ index 3b785a3ade..e51e3b74cc 100644
this.world.getMethodProfiler().exit();
ChunkCoordIntPair chunkcoordintpair = playerchunk.i();
@@ -449,9 +459,9 @@ public class ChunkProviderServer extends IChunkProvider {
- if (!this.playerChunkMap.isOutsideOfRange(chunkcoordintpair)) {
+ // Paper start - timings
+ this.world.timings.chunkRangeCheckBig.startTiming();
+ // note: this is just a copy of the expression in the if
+ boolean bigRadiusOutsideRange = !this.playerChunkMap.isOutsideOfRange(chunkcoordintpair);
+ this.world.timings.chunkRangeCheckBig.stopTiming();
+ if (bigRadiusOutsideRange) {
+ // Paper end
chunk.b(chunk.q() + j);
- if (flag1 && (this.allowMonsters || this.allowAnimals) && this.world.getWorldBorder().isInBounds(chunk.getPos()) && !this.playerChunkMap.isOutsideOfRange(chunkcoordintpair, true)) { // Spigot
+ // Paper start - timings
+ this.world.timings.chunkRangeCheckSmall.startTiming();
+ // note: this is just a copy of the expression in the if
+ boolean smallRadiusOutsideRange = flag1 && (this.allowMonsters || this.allowAnimals) && this.world.getWorldBorder().isInBounds(chunk.getPos()) && !this.playerChunkMap.isOutsideOfRange(chunkcoordintpair, true);
+ this.world.timings.chunkRangeCheckSmall.stopTiming();
+ if (smallRadiusOutsideRange) { // Spigot
+ // Paper end
this.world.getMethodProfiler().enter("spawner");
this.world.timings.mobSpawn.startTiming(); // Spigot
EnumCreatureType[] aenumcreaturetype1 = aenumcreaturetype;
@@ -449,24 +471,24 @@ public class ChunkProviderServer extends IChunkProvider {
this.world.getMethodProfiler().exit();
}
@ -433,7 +463,14 @@ index 3b785a3ade..e51e3b74cc 100644
}
}
});
@@ -464,9 +474,7 @@ public class ChunkProviderServer extends IChunkProvider {
this.world.getMethodProfiler().enter("customSpawners");
if (flag1) {
+ try (co.aikar.timings.Timing ignored = this.world.timings.miscMobSpawning.startTiming()) { // Paper - timings
this.chunkGenerator.doMobSpawning(this.world, this.allowMonsters, this.allowAnimals);
+ } // Paper - timings
}
this.world.getMethodProfiler().exit();
this.world.getMethodProfiler().exit();
}

View file

@ -1,4 +1,4 @@
From 93c8ba8e954ae57dbee91a39cea5c6cb1dd6524d Mon Sep 17 00:00:00 2001
From 9413728661866351fccf0d24d8c332f7e53c9ec1 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Sat, 13 Jul 2019 09:23:10 -0700
Subject: [PATCH] Asynchronous chunk IO and loading
@ -121,12 +121,12 @@ tasks required to be executed by the chunk load task (i.e lighting
and some poi tasks).
diff --git a/src/main/java/co/aikar/timings/WorldTimingsHandler.java b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
index 92c32c48d2..f4d5db02f7 100644
index 3a79cde595..8de6c4816c 100644
--- a/src/main/java/co/aikar/timings/WorldTimingsHandler.java
+++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
@@ -58,6 +58,17 @@ public class WorldTimingsHandler {
public final Timing worldSaveLevel;
public final Timing chunkSaveData;
@@ -63,6 +63,17 @@ public class WorldTimingsHandler {
public final Timing chunkRangeCheckBig;
public final Timing chunkRangeCheckSmall;
+ public final Timing poiUnload;
+ public final Timing chunkUnload;
@ -142,10 +142,10 @@ index 92c32c48d2..f4d5db02f7 100644
public WorldTimingsHandler(World server) {
String name = server.worldData.getName() +" - ";
@@ -112,6 +123,17 @@ public class WorldTimingsHandler {
chunkProviderTick = Timings.ofSafe(name + "Chunk provider tick");
broadcastChunkUpdates = Timings.ofSafe(name + "Broadcast chunk updates");
countNaturalMobs = Timings.ofSafe(name + "Count natural mobs");
@@ -122,6 +133,17 @@ public class WorldTimingsHandler {
miscMobSpawning = Timings.ofSafe(name + "Mob spawning - Misc");
chunkRangeCheckBig = Timings.ofSafe(name + "Chunk Tick Range - Big");
chunkRangeCheckSmall = Timings.ofSafe(name + "Chunk Tick Range - Small");
+
+ poiUnload = Timings.ofSafe(name + "Chunk unload - POI");
+ chunkUnload = Timings.ofSafe(name + "Chunk unload - Chunk");
@ -2347,7 +2347,7 @@ index 0000000000..1d69715e26
+
+}
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index e0bd03b3be..f793ba08e7 100644
index 56761afdf4..277c2245d7 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -124,11 +124,137 @@ public class ChunkProviderServer extends IChunkProvider {
@ -2502,7 +2502,7 @@ index e0bd03b3be..f793ba08e7 100644
this.world.timings.chunkAwait.stopTiming(); // Paper
} // Paper
ichunkaccess = (IChunkAccess) ((Either) completablefuture.join()).map((ichunkaccess1) -> {
@@ -627,11 +758,12 @@ public class ChunkProviderServer extends IChunkProvider {
@@ -641,11 +772,12 @@ public class ChunkProviderServer extends IChunkProvider {
protected boolean executeNext() {
// CraftBukkit start - process pending Chunk loadCallback() and unloadCallback() after each run task
try {
@ -2897,7 +2897,7 @@ index 23d1935dd5..14f8b61042 100644
+ }
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 2293360407..d2c0299730 100644
index ccf359dff1..a256f043ad 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -774,6 +774,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas

View file

@ -1,14 +1,14 @@
From 576204ff82d9ca1e4317c2be63e6be359dabf74c Mon Sep 17 00:00:00 2001
From 1cf6d39b92813916f3e9493764b19b226e03f1ba Mon Sep 17 00:00:00 2001
From: kickash32 <kickash32@gmail.com>
Date: Mon, 19 Aug 2019 01:27:58 +0500
Subject: [PATCH] implement optional per player mob spawns
diff --git a/src/main/java/co/aikar/timings/WorldTimingsHandler.java b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
index f4d5db02f..24b4c6e6a 100644
index 8de6c4816c..ddec62fbf5 100644
--- a/src/main/java/co/aikar/timings/WorldTimingsHandler.java
+++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
@@ -69,6 +69,8 @@ public class WorldTimingsHandler {
@@ -74,6 +74,8 @@ public class WorldTimingsHandler {
public final Timing chunkUnloadPOISerialization;
public final Timing chunkUnloadDataSave;
@ -17,7 +17,7 @@ index f4d5db02f..24b4c6e6a 100644
public WorldTimingsHandler(World server) {
String name = server.worldData.getName() +" - ";
@@ -134,6 +136,8 @@ public class WorldTimingsHandler {
@@ -144,6 +146,8 @@ public class WorldTimingsHandler {
chunkUnloadPrepareSave = Timings.ofSafe(name + "Chunk unload - Async Save Prepare");
chunkUnloadPOISerialization = Timings.ofSafe(name + "Chunk unload - POI Data Serialization");
chunkUnloadDataSave = Timings.ofSafe(name + "Chunk unload - Data Serialization");
@ -27,7 +27,7 @@ index f4d5db02f..24b4c6e6a 100644
public static Timing getTickList(WorldServer worldserver, String timingsType) {
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index e7bbeef74..246bb4b01 100644
index e7bbeef74d..246bb4b014 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -615,4 +615,9 @@ public class PaperWorldConfig {
@ -42,7 +42,7 @@ index e7bbeef74..246bb4b01 100644
}
diff --git a/src/main/java/com/destroystokyo/paper/util/PlayerMobDistanceMap.java b/src/main/java/com/destroystokyo/paper/util/PlayerMobDistanceMap.java
new file mode 100644
index 000000000..9ebd7ecb7
index 0000000000..9ebd7ecb7a
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/util/PlayerMobDistanceMap.java
@@ -0,0 +1,253 @@
@ -301,7 +301,7 @@ index 000000000..9ebd7ecb7
+}
diff --git a/src/main/java/com/destroystokyo/paper/util/PooledHashSets.java b/src/main/java/com/destroystokyo/paper/util/PooledHashSets.java
new file mode 100644
index 000000000..4f13d3ff8
index 0000000000..4f13d3ff83
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/util/PooledHashSets.java
@@ -0,0 +1,241 @@
@ -547,7 +547,7 @@ index 000000000..4f13d3ff8
+ }
+}
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index c8451afec..d0606ee74 100644
index 8d7971ad80..e7539dd791 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -555,7 +555,22 @@ public class ChunkProviderServer extends IChunkProvider {
@ -574,7 +574,7 @@ index c8451afec..d0606ee74 100644
this.world.timings.countNaturalMobs.stopTiming(); // Paper - timings
this.world.getMethodProfiler().exit();
@@ -608,8 +623,23 @@ public class ChunkProviderServer extends IChunkProvider {
@@ -620,8 +635,23 @@ public class ChunkProviderServer extends IChunkProvider {
if (enumcreaturetype != EnumCreatureType.MISC && (!enumcreaturetype.c() || this.allowAnimals) && (enumcreaturetype.c() || this.allowMonsters) && (!enumcreaturetype.d() || flag2)) {
int k1 = limit * l / ChunkProviderServer.b; // CraftBukkit - use per-world limits
@ -601,7 +601,7 @@ index c8451afec..d0606ee74 100644
}
}
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 0e29858c0..7801879c8 100644
index 0e29858c08..7801879c87 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -80,6 +80,11 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
@ -633,7 +633,7 @@ index 0e29858c0..7801879c8 100644
return this.cv;
}
diff --git a/src/main/java/net/minecraft/server/EntityTypes.java b/src/main/java/net/minecraft/server/EntityTypes.java
index a7fc34f85..612b9b7e3 100644
index a7fc34f850..612b9b7e33 100644
--- a/src/main/java/net/minecraft/server/EntityTypes.java
+++ b/src/main/java/net/minecraft/server/EntityTypes.java
@@ -253,6 +253,7 @@ public class EntityTypes<T extends Entity> {
@ -645,7 +645,7 @@ index a7fc34f85..612b9b7e3 100644
return this.ba;
}
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index 9daf64bad..95ee33513 100644
index 9daf64bad4..95ee335135 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -77,7 +77,8 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@ -684,7 +684,7 @@ index 9daf64bad..95ee33513 100644
private static double a(ChunkCoordIntPair chunkcoordintpair, Entity entity) {
diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java
index c6ea37ffb..9d4a96ae4 100644
index c6ea37ffbd..9d4a96ae49 100644
--- a/src/main/java/net/minecraft/server/SpawnerCreature.java
+++ b/src/main/java/net/minecraft/server/SpawnerCreature.java
@@ -3,6 +3,7 @@ package net.minecraft.server;
@ -757,7 +757,7 @@ index c6ea37ffb..9d4a96ae4 100644
@Nullable
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 845575f52..ee3789b38 100644
index 845575f52e..ee3789b38c 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -964,7 +964,20 @@ public class WorldServer extends World {
@ -802,5 +802,5 @@ index 845575f52..ee3789b38 100644
@Override
--
2.23.0
2.22.1