Reduce chunk range timers

This commit is contained in:
Shane Freeder 2020-03-02 19:56:04 +00:00
parent 793bae0d45
commit 3ad47bcf8e
No known key found for this signature in database
GPG Key ID: A3F61EA5A085289C
3 changed files with 32 additions and 47 deletions

View File

@ -1,4 +1,4 @@
From f9787ca0388662098768e6d0f11a359990dbeec2 Mon Sep 17 00:00:00 2001
From 9aca88887465870a1089eb904cb3aaefd7cbf0d4 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
@ -153,10 +153,10 @@ index 0000000000..69e26a8267
+}
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..3a79cde595
index 0000000000..e41083f14c
--- /dev/null
+++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
@@ -0,0 +1,130 @@
@@ -0,0 +1,128 @@
+package co.aikar.timings;
+
+import net.minecraft.server.World;
@ -219,8 +219,7 @@ index 0000000000..3a79cde595
+
+
+ public final Timing miscMobSpawning;
+ public final Timing chunkRangeCheckBig;
+ public final Timing chunkRangeCheckSmall;
+ public final Timing chunkInhibitedRangeCheck;
+
+ public WorldTimingsHandler(World server) {
+ String name = server.worldData.getName() +" - ";
@ -278,9 +277,8 @@ index 0000000000..3a79cde595
+ countNaturalMobs = Timings.ofSafe(name + "Count natural mobs");
+
+
+ chunkInhibitedRangeCheck = Timings.ofSafe(name + "Chunks - Inhibited Range Check");
+ 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) {
@ -375,7 +373,7 @@ index e58dd3e6df..0b32179b79 100644
}
}
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index f558ae4417..2107ddc48f 100644
index f558ae4417..63cb0019b1 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -227,11 +227,13 @@ public class ChunkProviderServer extends IChunkProvider {
@ -427,7 +425,7 @@ index f558ae4417..2107ddc48f 100644
this.world.getMethodProfiler().exit();
this.playerChunkMap.f().forEach((playerchunk) -> {
Optional<Chunk> optional = ((Either) playerchunk.b().getNow(PlayerChunk.UNLOADED_CHUNK)).left();
@@ -498,13 +506,27 @@ public class ChunkProviderServer extends IChunkProvider {
@@ -498,11 +506,15 @@ public class ChunkProviderServer extends IChunkProvider {
Chunk chunk = (Chunk) optional.get();
this.world.getMethodProfiler().enter("broadcast");
@ -437,27 +435,13 @@ index f558ae4417..2107ddc48f 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) {
+ this.world.timings.chunkInhibitedRangeCheck.startTiming();
if (!this.playerChunkMap.isOutsideOfRange(chunkcoordintpair)) {
+ // Paper end
chunk.setInhabitedTime(chunk.getInhabitedTime() + 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
if (flag1 && (this.allowMonsters || this.allowAnimals) && this.world.getWorldBorder().isInBounds(chunk.getPos()) && !this.playerChunkMap.isOutsideOfRange(chunkcoordintpair, true)) { // Spigot
this.world.getMethodProfiler().enter("spawner");
this.world.timings.mobSpawn.startTiming(); // Spigot
EnumCreatureType[] aenumcreaturetype1 = aenumcreaturetype;
@@ -548,24 +570,24 @@ public class ChunkProviderServer extends IChunkProvider {
@@ -548,24 +560,25 @@ public class ChunkProviderServer extends IChunkProvider {
this.world.getMethodProfiler().exit();
}
@ -467,6 +451,7 @@ index f558ae4417..2107ddc48f 100644
- this.world.timings.doTickTiles.stopTiming(); // Spigot
+ this.world.timings.chunkTicks.stopTiming(); // Spigot // Paper
}
+ this.world.timings.chunkInhibitedRangeCheck.stopTiming(); // Paper
}
});
this.world.getMethodProfiler().enter("customSpawners");

View File

@ -1,4 +1,4 @@
From 966c7f77bdfad41e7191a805034ed36f70e849e0 Mon Sep 17 00:00:00 2001
From eaec5bfc7161e0448b6c9ac2d7b4a924338c771c 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 3a79cde595..8de6c4816c 100644
index e41083f14c..8a3f30c36f 100644
--- a/src/main/java/co/aikar/timings/WorldTimingsHandler.java
+++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
@@ -63,6 +63,17 @@ public class WorldTimingsHandler {
public final Timing chunkRangeCheckBig;
public final Timing chunkRangeCheckSmall;
@@ -62,6 +62,17 @@ public class WorldTimingsHandler {
public final Timing miscMobSpawning;
public final Timing chunkInhibitedRangeCheck;
+ public final Timing poiUnload;
+ public final Timing chunkUnload;
@ -142,10 +142,10 @@ index 3a79cde595..8de6c4816c 100644
public WorldTimingsHandler(World server) {
String name = server.worldData.getName() +" - ";
@@ -122,6 +133,17 @@ public class WorldTimingsHandler {
@@ -120,6 +131,17 @@ public class WorldTimingsHandler {
chunkInhibitedRangeCheck = Timings.ofSafe(name + "Chunks - Inhibited Range Check");
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");
@ -2361,7 +2361,7 @@ index 0000000000..715a2dd8d2
+
+}
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 296f69a0ac..31377fd4af 100644
index a57371b08e..e8166bc812 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -218,11 +218,137 @@ public class ChunkProviderServer extends IChunkProvider {
@ -2516,7 +2516,7 @@ index 296f69a0ac..31377fd4af 100644
this.world.timings.chunkAwait.stopTiming(); // Paper
} // Paper
ichunkaccess = (IChunkAccess) ((Either) completablefuture.join()).map((ichunkaccess1) -> {
@@ -754,11 +885,12 @@ public class ChunkProviderServer extends IChunkProvider {
@@ -745,11 +876,12 @@ public class ChunkProviderServer extends IChunkProvider {
protected boolean executeNext() {
// CraftBukkit start - process pending Chunk loadCallback() and unloadCallback() after each run task
try {

View File

@ -1,25 +1,25 @@
From 9ee9808e7cd582a872291765508cff73f7d80bd5 Mon Sep 17 00:00:00 2001
From 8b3e0e6199516a840742e4be0f08bde29eaf339a 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 8de6c4816c..e25544f116 100644
index 8a3f30c36f..51281cfa2d 100644
--- a/src/main/java/co/aikar/timings/WorldTimingsHandler.java
+++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
@@ -62,6 +62,7 @@ public class WorldTimingsHandler {
@@ -61,6 +61,7 @@ public class WorldTimingsHandler {
public final Timing miscMobSpawning;
public final Timing chunkRangeCheckBig;
public final Timing chunkRangeCheckSmall;
public final Timing chunkInhibitedRangeCheck;
+ public final Timing playerMobDistanceMapUpdate;
public final Timing poiUnload;
public final Timing chunkUnload;
@@ -133,6 +134,7 @@ public class WorldTimingsHandler {
@@ -131,6 +132,7 @@ public class WorldTimingsHandler {
chunkInhibitedRangeCheck = Timings.ofSafe(name + "Chunks - Inhibited Range Check");
miscMobSpawning = Timings.ofSafe(name + "Mob spawning - Misc");
chunkRangeCheckBig = Timings.ofSafe(name + "Chunk Tick Range - Big");
chunkRangeCheckSmall = Timings.ofSafe(name + "Chunk Tick Range - Small");
+ playerMobDistanceMapUpdate = Timings.ofSafe(name + "Per Player Mob Spawning - Distance Map Update");
poiUnload = Timings.ofSafe(name + "Chunk unload - POI");
@ -545,7 +545,7 @@ index 0000000000..4f13d3ff83
+ }
+}
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 93b4e6117f..7db96cec40 100644
index 6adb31d854..a0839ac725 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -654,7 +654,22 @@ public class ChunkProviderServer extends IChunkProvider {
@ -572,7 +572,7 @@ index 93b4e6117f..7db96cec40 100644
this.world.timings.countNaturalMobs.stopTiming(); // Paper - timings
this.world.getMethodProfiler().exit();
@@ -728,8 +743,23 @@ public class ChunkProviderServer extends IChunkProvider {
@@ -718,8 +733,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