3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-15 11:00:06 +01:00

Do not tick Chunk TickS for every chunk

Dieser Commit ist enthalten in:
Shane Freeder 2021-06-03 06:13:18 +01:00
Ursprung af1a50993f
Commit 12716324d9
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: A3F61EA5A085289C
9 geänderte Dateien mit 39 neuen und 34 gelöschten Zeilen

Datei anzeigen

@ -1063,7 +1063,7 @@ index 8e2e415a022ccd486465f19d9bbf1f287b21fb95..59942eb6bb6e8e1e9a988bce0d09757e
}
diff --git a/src/main/java/net/minecraft/server/level/ChunkProviderServer.java b/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
index 0b5bcb60472c778574702a5ac26a6d02d54bfeac..9ed97d5db81e3603ccccca7500420d7e401ef2a5 100644
index 0b5bcb60472c778574702a5ac26a6d02d54bfeac..3351c6bcc5244fd7565ba7af08f63ea4d999ce97 100644
--- a/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
@@ -344,11 +344,13 @@ public class ChunkProviderServer extends IChunkProvider {
@ -1102,7 +1102,7 @@ index 0b5bcb60472c778574702a5ac26a6d02d54bfeac..9ed97d5db81e3603ccccca7500420d7e
this.world.timings.doChunkUnload.startTiming(); // Spigot
this.world.getMethodProfiler().exitEnter("unload");
this.playerChunkMap.unloadChunks(booleansupplier);
@@ -596,8 +602,10 @@ public class ChunkProviderServer extends IChunkProvider {
@@ -596,19 +602,24 @@ public class ChunkProviderServer extends IChunkProvider {
boolean flag2 = world.ticksPerAnimalSpawns != 0L && worlddata.getTime() % world.ticksPerAnimalSpawns == 0L; // CraftBukkit
this.world.getMethodProfiler().enter("naturalSpawnCount");
@ -1113,7 +1113,11 @@ index 0b5bcb60472c778574702a5ac26a6d02d54bfeac..9ed97d5db81e3603ccccca7500420d7e
this.p = spawnercreature_d;
this.world.getMethodProfiler().exit();
@@ -608,7 +616,9 @@ public class ChunkProviderServer extends IChunkProvider {
//List<PlayerChunk> list = Lists.newArrayList(this.playerChunkMap.f()); // Paper
//Collections.shuffle(list); // Paper
+ this.world.timings.chunkTicks.startTiming(); // Paper
this.playerChunkMap.f().forEach((playerchunk) -> { // Paper - no... just no...
Optional<Chunk> optional = ((Either) playerchunk.a().getNow(PlayerChunk.UNLOADED_CHUNK)).left();
if (optional.isPresent()) {
this.world.getMethodProfiler().enter("broadcast");
@ -1123,19 +1127,20 @@ index 0b5bcb60472c778574702a5ac26a6d02d54bfeac..9ed97d5db81e3603ccccca7500420d7e
this.world.getMethodProfiler().exit();
Optional<Chunk> optional1 = ((Either) playerchunk.b().getNow(PlayerChunk.UNLOADED_CHUNK)).left();
@@ -622,25 +632,25 @@ public class ChunkProviderServer extends IChunkProvider {
@@ -622,25 +633,26 @@ public class ChunkProviderServer extends IChunkProvider {
SpawnerCreature.a(this.world, chunk, spawnercreature_d, this.allowAnimals, this.allowMonsters, flag2);
}
- this.world.timings.doTickTiles.startTiming(); // Spigot
+ this.world.timings.chunkTicks.startTiming(); // Spigot // Paper
+ //this.world.timings.chunkTicks.startTiming(); // Spigot // Paper
this.world.a(chunk, k);
- this.world.timings.doTickTiles.stopTiming(); // Spigot
+ this.world.timings.chunkTicks.stopTiming(); // Spigot // Paper
+ //this.world.timings.chunkTicks.stopTiming(); // Spigot // Paper
}
}
}
});
+ this.world.timings.chunkTicks.stopTiming(); // Paper
this.world.getMethodProfiler().enter("customSpawners");
if (flag1) {
+ try (co.aikar.timings.Timing ignored = this.world.timings.miscMobSpawning.startTiming()) { // Paper - timings

Datei anzeigen

@ -9,7 +9,7 @@ from triggering monster spawns on a server.
Also a highly more effecient way to blanket block spawns in a world
diff --git a/src/main/java/net/minecraft/server/level/ChunkProviderServer.java b/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
index 9ed97d5db81e3603ccccca7500420d7e401ef2a5..b9bde85a90b429659e1a4ab111253cddd797368e 100644
index 3351c6bcc5244fd7565ba7af08f63ea4d999ce97..677c185aca2cdd64bead9dbed147a87c5bcf1678 100644
--- a/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
@@ -611,6 +611,15 @@ public class ChunkProviderServer extends IChunkProvider {
@ -25,9 +25,9 @@ index 9ed97d5db81e3603ccccca7500420d7e401ef2a5..b9bde85a90b429659e1a4ab111253cdd
+ entityPlayer.playerNaturallySpawnedEvent.callEvent();
+ };
+ // Paper end
this.world.timings.chunkTicks.startTiming(); // Paper
this.playerChunkMap.f().forEach((playerchunk) -> { // Paper - no... just no...
Optional<Chunk> optional = ((Either) playerchunk.a().getNow(PlayerChunk.UNLOADED_CHUNK)).left();
diff --git a/src/main/java/net/minecraft/server/level/EntityPlayer.java b/src/main/java/net/minecraft/server/level/EntityPlayer.java
index 5b2ae94ed7d499e401a058691eb6ed413b626150..de7167ddf7b36ef266e511187789f99244401c21 100644
--- a/src/main/java/net/minecraft/server/level/EntityPlayer.java

Datei anzeigen

@ -8,7 +8,7 @@ This patch also adds a chunk status cache on region files (note that
its only purpose is to cache the status on DISK)
diff --git a/src/main/java/net/minecraft/server/level/ChunkProviderServer.java b/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
index 94af98e250fe7ef37c16d432c05c6f2b68625fe1..f2d48659fdb9f030dbeec12ed820062d4d066e48 100644
index 3425ae4d036bbfa413e60eccfd6d82b8dae3775b..34b68443ff300f8626e9f7a8335cff75580bebfc 100644
--- a/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
@@ -52,7 +52,7 @@ public class ChunkProviderServer extends IChunkProvider {
@ -42,7 +42,7 @@ index 94af98e250fe7ef37c16d432c05c6f2b68625fe1..f2d48659fdb9f030dbeec12ed820062d
// Paper end
@Nullable
@@ -768,7 +783,7 @@ public class ChunkProviderServer extends IChunkProvider {
@@ -770,7 +785,7 @@ public class ChunkProviderServer extends IChunkProvider {
return this.p;
}

Datei anzeigen

@ -2348,7 +2348,7 @@ index 191a74bd9b894f9d64d0a55747cb17e07ceef597..1732fc552c290d294b68d6f92f2a58d9
DedicatedServer dedicatedserver1 = new DedicatedServer(optionset, datapackconfiguration1, thread, iregistrycustom_dimension, convertable_conversionsession, resourcepackrepository, datapackresources, null, dedicatedserversettings, DataConverterRegistry.a(), minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new);
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 571f3860bc31c077c239a32776f6aaf6ff30ce71..ef13e310a8a452d2ba1d9c8bac72f9baf2693de0 100644
index 8b922136336d5dc8fc302cc0f4879c4968a1cc67..e6e8ab0b39a11b0aed247b9b80a6c1f97505546b 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -922,7 +922,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@ -2361,7 +2361,7 @@ index 571f3860bc31c077c239a32776f6aaf6ff30ce71..ef13e310a8a452d2ba1d9c8bac72f9ba
public String getServerIp() {
diff --git a/src/main/java/net/minecraft/server/level/ChunkProviderServer.java b/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
index 5122afbd51c87c27efa82d7d9393f252efa848d4..1e74299bb3a368dcbc813408804d25cf58a75b0b 100644
index 8c497da1a4bde904e234a8fa00bf04a12787c7ed..2a5df37a94b4b609a2d1b045f8e6a7f08d3f8eaa 100644
--- a/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
@@ -38,6 +38,7 @@ import net.minecraft.world.level.chunk.ChunkGenerator;
@ -2541,7 +2541,7 @@ index 5122afbd51c87c27efa82d7d9393f252efa848d4..1e74299bb3a368dcbc813408804d25cf
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i, j);
long k = chunkcoordintpair.pair();
int l = 33 + ChunkStatus.a(chunkstatus);
@@ -828,11 +966,12 @@ public class ChunkProviderServer extends IChunkProvider {
@@ -830,11 +968,12 @@ public class ChunkProviderServer extends IChunkProvider {
protected boolean executeNext() {
// CraftBukkit start - process pending Chunk loadCallback() and unloadCallback() after each run task
try {
@ -3071,7 +3071,7 @@ index 285a03b57431bd6a4d26bb84e916d2c6e1eb0213..218dc900e125a11548485887b1918742
public static <T> TicketType<T> a(String s, Comparator<T> comparator) {
return new TicketType<>(s, comparator, 0L);
diff --git a/src/main/java/net/minecraft/server/level/WorldServer.java b/src/main/java/net/minecraft/server/level/WorldServer.java
index 9012c837c2f284e9f2f11462e6dc7e2f6e190939..bb6c59237702bf82d2c344c864f233c606fd429f 100644
index 3eb337d42f0292ed7b85a5fdbf6b450bc446b81a..52d22da115212eae6c380bb5012398e3df92f5f3 100644
--- a/src/main/java/net/minecraft/server/level/WorldServer.java
+++ b/src/main/java/net/minecraft/server/level/WorldServer.java
@@ -51,6 +51,7 @@ import net.minecraft.core.IRegistry;
@ -3192,7 +3192,7 @@ index 9012c837c2f284e9f2f11462e6dc7e2f6e190939..bb6c59237702bf82d2c344c864f233c6
}
public void removeTicketsForSpawn(int radiusInBlocks, BlockPosition spawn) {
diff --git a/src/main/java/net/minecraft/server/network/PlayerConnection.java b/src/main/java/net/minecraft/server/network/PlayerConnection.java
index d84d87b0dd01b4d67e55f1b445928285c45a08ca..fa0b7edf42243d53d9dc897903b9b9e902b33cf7 100644
index c3a3837badb4b2a2ab51e6fb2d7cfbaa2f4d8edb..d74d6abfff647c148e524905cd733c4b7fc6591f 100644
--- a/src/main/java/net/minecraft/server/network/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/network/PlayerConnection.java
@@ -730,6 +730,13 @@ public class PlayerConnection implements PacketListenerPlayIn {

Datei anzeigen

@ -70,13 +70,13 @@ index 5a410550cfb48505c9de9979465ed1528c8fbf05..9edbde8299bcd127e1727d34ed441f63
List<PlayerChunk> allChunks = new ArrayList<>(visibleChunks.values());
List<EntityPlayer> players = world.players;
diff --git a/src/main/java/net/minecraft/server/level/ChunkProviderServer.java b/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
index a444f6214b90f7707be2265f4b2ab12632986c53..138676e5b03bc80a777a1f4c12f3f4b5316e8dea 100644
index 214098d7ad95839e90b0ec9ea997930c27b4bea4..13ac946487bb05b5c47ee8ee10cb6ed1c992c0e2 100644
--- a/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
@@ -780,7 +780,7 @@ public class ChunkProviderServer extends IChunkProvider {
entityPlayer.playerNaturallySpawnedEvent.callEvent();
@@ -781,7 +781,7 @@ public class ChunkProviderServer extends IChunkProvider {
};
// Paper end
this.world.timings.chunkTicks.startTiming(); // Paper
- this.playerChunkMap.f().forEach((playerchunk) -> { // Paper - no... just no...
+ this.playerChunkMap.forEachVisibleChunk((playerchunk) -> { // Paper - safe iterator incase chunk loads, also no wrapping
Optional<Chunk> optional = ((Either) playerchunk.a().getNow(PlayerChunk.UNLOADED_CHUNK)).left();

Datei anzeigen

@ -56,7 +56,7 @@ index da93d38fe63035e4ff198ada84a4431f52d97c01..ddbc8cb712c50038922eded75dd6ca85
+ }
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 54738ef346b1fe4c45ea95db2f236d10f8525a20..5ea593ccfedf55140a723f6dc29bebe282e77ab3 100644
index 34c273178e711466ec6638f24e0371554e26e134..cb15606d528b2f94103d347ad89d3836fa93c360 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1057,6 +1057,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@ -147,7 +147,7 @@ index 54738ef346b1fe4c45ea95db2f236d10f8525a20..5ea593ccfedf55140a723f6dc29bebe2
// Spigot Start
CrashReport crashreport;
diff --git a/src/main/java/net/minecraft/server/level/ChunkProviderServer.java b/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
index 138676e5b03bc80a777a1f4c12f3f4b5316e8dea..99108d2c8145c16943fb29872c55d8e74f75eb77 100644
index 13ac946487bb05b5c47ee8ee10cb6ed1c992c0e2..48d0c37a1d7df9b7ac8077e1e82420566dc42718 100644
--- a/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
@@ -22,6 +22,7 @@ import net.minecraft.core.BlockPosition;
@ -174,24 +174,24 @@ index 138676e5b03bc80a777a1f4c12f3f4b5316e8dea..99108d2c8145c16943fb29872c55d8e7
this.world.timings.doChunkUnload.stopTiming(); // Spigot
this.world.getMethodProfiler().exit();
this.clearCache();
@@ -780,7 +783,7 @@ public class ChunkProviderServer extends IChunkProvider {
entityPlayer.playerNaturallySpawnedEvent.callEvent();
@@ -781,7 +784,7 @@ public class ChunkProviderServer extends IChunkProvider {
};
// Paper end
this.world.timings.chunkTicks.startTiming(); // Paper
- this.playerChunkMap.forEachVisibleChunk((playerchunk) -> { // Paper - safe iterator incase chunk loads, also no wrapping
+ final int[] chunksTicked = {0}; this.playerChunkMap.forEachVisibleChunk((playerchunk) -> { // Paper - safe iterator incase chunk loads, also no wrapping
Optional<Chunk> optional = ((Either) playerchunk.a().getNow(PlayerChunk.UNLOADED_CHUNK)).left();
if (optional.isPresent()) {
@@ -804,6 +807,7 @@ public class ChunkProviderServer extends IChunkProvider {
this.world.timings.chunkTicks.startTiming(); // Spigot // Paper
@@ -805,6 +808,7 @@ public class ChunkProviderServer extends IChunkProvider {
//this.world.timings.chunkTicks.startTiming(); // Spigot // Paper
this.world.a(chunk, k);
this.world.timings.chunkTicks.stopTiming(); // Spigot // Paper
//this.world.timings.chunkTicks.stopTiming(); // Spigot // Paper
+ if (chunksTicked[0]++ % 10 == 0) this.world.getMinecraftServer().midTickLoadChunks(); // Paper
}
}
}
@@ -960,6 +964,41 @@ public class ChunkProviderServer extends IChunkProvider {
@@ -962,6 +966,41 @@ public class ChunkProviderServer extends IChunkProvider {
super.executeTask(runnable);
}
@ -234,7 +234,7 @@ index 138676e5b03bc80a777a1f4c12f3f4b5316e8dea..99108d2c8145c16943fb29872c55d8e7
protected boolean executeNext() {
// CraftBukkit start - process pending Chunk loadCallback() and unloadCallback() after each run task
diff --git a/src/main/java/net/minecraft/server/level/WorldServer.java b/src/main/java/net/minecraft/server/level/WorldServer.java
index 8159baec6e862580dc340d8fd7c16013ec8f0e66..6f15e2d0302108d64b14b3449e81f18f985db7ae 100644
index 35fc51ac93a62f6dc4b141dc94a3cda0399f0ce1..ce0bbd6fb467c84d14fa4eaa8f80ed5b261e07bd 100644
--- a/src/main/java/net/minecraft/server/level/WorldServer.java
+++ b/src/main/java/net/minecraft/server/level/WorldServer.java
@@ -571,6 +571,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {

Datei anzeigen

@ -25,10 +25,10 @@ This successfully fixed a reoccurring and highly reproduceable crash
for heightmaps.
diff --git a/src/main/java/net/minecraft/server/level/ChunkProviderServer.java b/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
index 2d7d2e712a7117e6985e3104097a31a5577c1b82..6e5d21af43261dc2f12ceec7b7e3269be635cf7a 100644
index d8355caf6f86e0bb8c16ad0b58b81d7926bc7bff..cb098defa7b93864294befa9b9a427804461188b 100644
--- a/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
@@ -1019,6 +1019,7 @@ public class ChunkProviderServer extends IChunkProvider {
@@ -1021,6 +1021,7 @@ public class ChunkProviderServer extends IChunkProvider {
return super.executeNext() || execChunkTask; // Paper
}
} finally {

Datei anzeigen

@ -77,7 +77,7 @@ index 60fcea78bf617559114b1ca1c0bf2d4cd9075a8c..335666db1854e8aa4b2ba71d5bdc2658
public String c() {
diff --git a/src/main/java/net/minecraft/server/level/ChunkProviderServer.java b/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
index ecf4cd6dfea777ab9daea0b40724d247df7ddb53..42bb00364375e5cf324b43557385345868b37ffe 100644
index fc7140e0eb11e4bec99e453647fce200bca0ed7f..46a2e89df71654024102427859c385fc2e09cae7 100644
--- a/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
@@ -753,6 +753,37 @@ public class ChunkProviderServer extends IChunkProvider {
@ -132,10 +132,10 @@ index ecf4cd6dfea777ab9daea0b40724d247df7ddb53..42bb00364375e5cf324b435573853458
- };
- // Paper end
+ // Paper - moved up
this.world.timings.chunkTicks.startTiming(); // Paper
final int[] chunksTicked = {0}; this.playerChunkMap.forEachVisibleChunk((playerchunk) -> { // Paper - safe iterator incase chunk loads, also no wrapping
Optional<Chunk> optional = ((Either) playerchunk.a().getNow(PlayerChunk.UNLOADED_CHUNK)).left();
@@ -806,9 +829,9 @@ public class ChunkProviderServer extends IChunkProvider {
@@ -807,9 +830,9 @@ public class ChunkProviderServer extends IChunkProvider {
Chunk chunk = (Chunk) optional1.get();
ChunkCoordIntPair chunkcoordintpair = playerchunk.i();

Datei anzeigen

@ -25,10 +25,10 @@ Massive update to light to improve performance and chunk loading/generation.
8) Fix NPE risk that crashes server in getting nibble data
diff --git a/src/main/java/net/minecraft/server/level/ChunkProviderServer.java b/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
index 19e02d12bb0c5a73066f7c57da40277918276210..326c52f9f2cc729fd52162aeae18ec9dae3a4eaf 100644
index 17a4970cf78f3ee3a62a76a3f9e28251db17bac2..6770307d69c6b3934bfa804fd713cade22f0fb5c 100644
--- a/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
@@ -1070,7 +1070,7 @@ public class ChunkProviderServer extends IChunkProvider {
@@ -1072,7 +1072,7 @@ public class ChunkProviderServer extends IChunkProvider {
if (ChunkProviderServer.this.tickDistanceManager()) {
return true;
} else {