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
parent 98854cdf4d
commit 0a5408a7d0
3 changed files with 58 additions and 21 deletions

View file

@ -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
@@ -0,0 +0,0 @@ public class WorldTimingsHandler {
public final Timing worldSaveLevel;
public final Timing chunkSaveData;
public final Timing chunkRangeCheckBig;
public final Timing chunkRangeCheckSmall;
+ public final Timing poiUnload;
+ public final Timing chunkUnload;
@ -143,9 +143,9 @@ index 92c32c48d2..f4d5db02f7 100644
String name = server.worldData.getName() +" - ";
@@ -0,0 +0,0 @@ public class WorldTimingsHandler {
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");
+
+ 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
@@ -0,0 +0,0 @@ public class ChunkProviderServer extends IChunkProvider {
@ -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
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas

View file

@ -147,7 +147,7 @@ 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 +0,0 @@
@ -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
@@ -0,0 +0,0 @@ public class ChunkProviderServer extends IChunkProvider {
@ -421,6 +431,26 @@ index 3b785a3ade..e51e3b74cc 100644
this.world.getMethodProfiler().exit();
ChunkCoordIntPair chunkcoordintpair = playerchunk.i();
- 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;
@@ -0,0 +0,0 @@ public class ChunkProviderServer extends IChunkProvider {
this.world.getMethodProfiler().exit();
}
@ -433,7 +463,14 @@ index 3b785a3ade..e51e3b74cc 100644
}
}
});
@@ -0,0 +0,0 @@ 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

@ -5,7 +5,7 @@ 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
@@ -0,0 +0,0 @@ public class WorldTimingsHandler {
@ -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
@@ -0,0 +0,0 @@ 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 +0,0 @@
@ -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 +0,0 @@
@ -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
@@ -0,0 +0,0 @@ public class ChunkProviderServer extends IChunkProvider {
@ -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
@@ -0,0 +0,0 @@ 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
@@ -0,0 +0,0 @@ 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
@@ -0,0 +0,0 @@ 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
@@ -0,0 +0,0 @@ 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
@@ -0,0 +0,0 @@ public class WorldServer extends World {