Add dropped hunk from mid-tick tasks (#7034)

This commit is contained in:
Jake Potrebic 2021-12-05 13:58:01 -08:00 committed by GitHub
parent 83aee0f551
commit 7c8fdc1fb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
75 changed files with 50 additions and 49 deletions

View File

@ -6511,7 +6511,7 @@ index bfcaaa69991342f71fba4df46f69aea2ec6adca7..0ea0690ab1d45f60a2b13cf8a69e5802
this.levelHeightAccessor = heightLimitView;
this.sections = new LevelChunkSection[heightLimitView.getSectionsCount()];
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index 28555314738ba891e0e36d3c85b1623116f743dd..3f09451a04404231f1eaac0954c0ecf01b7507ea 100644
index 28555314738ba891e0e36d3c85b1623116f743dd..0f8302c8fda85f8fb5cf24974d9013706dcc5a0a 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -24,6 +24,7 @@ import net.minecraft.nbt.CompoundTag;
@ -6528,7 +6528,7 @@ index 28555314738ba891e0e36d3c85b1623116f743dd..3f09451a04404231f1eaac0954c0ecf0
+ // Paper start
+ public final com.destroystokyo.paper.util.maplist.EntityList entities = new com.destroystokyo.paper.util.maplist.EntityList();
+ public ChunkHolder playerChunk;
+ public @Nullable ChunkHolder playerChunk;
+
+ static final int NEIGHBOUR_CACHE_RADIUS = 3;
+ public static int getNeighbourCacheRadius() {

View File

@ -6,10 +6,10 @@ Subject: [PATCH] Optimise chunk tick iteration
Use a dedicated list of entity ticking chunks to reduce the cost
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index 51c4ca36221e9af074fa92f6ab94fa7ba5403080..8d38a5a4c74d3f9298ba4f215e978fbc25ba91f0 100644
index 280ca8758cbaf710c2bf357e41dd2af6e14b49bc..4f502f1c8a86a28e2cd6513516f3846ed74be891 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -1001,34 +1001,46 @@ public class ServerChunkCache extends ChunkSource {
@@ -999,34 +999,46 @@ public class ServerChunkCache extends ChunkSource {
this.lastSpawnState = spawnercreature_d;
gameprofilerfiller.popPush("filteringLoadedChunks");
@ -72,7 +72,7 @@ index 51c4ca36221e9af074fa92f6ab94fa7ba5403080..8d38a5a4c74d3f9298ba4f215e978fbc
NaturalSpawner.spawnForChunk(this.level, chunk1, spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1);
}
@@ -1036,7 +1048,16 @@ public class ServerChunkCache extends ChunkSource {
@@ -1034,7 +1046,16 @@ public class ServerChunkCache extends ChunkSource {
this.level.tickChunk(chunk1, k);
}
}
@ -89,7 +89,7 @@ index 51c4ca36221e9af074fa92f6ab94fa7ba5403080..8d38a5a4c74d3f9298ba4f215e978fbc
this.level.timings.chunkTicks.stopTiming(); // Paper
gameprofilerfiller.popPush("customSpawners");
if (flag2) {
@@ -1045,13 +1066,7 @@ public class ServerChunkCache extends ChunkSource {
@@ -1043,13 +1064,7 @@ public class ServerChunkCache extends ChunkSource {
} // Paper - timings
}
@ -102,5 +102,5 @@ index 51c4ca36221e9af074fa92f6ab94fa7ba5403080..8d38a5a4c74d3f9298ba4f215e978fbc
- gameprofilerfiller.pop();
+ // Paper - no, iterating just ONCE is expensive enough! Don't do it TWICE! Code moved up
gameprofilerfiller.pop();
// Paper start - controlled flush for entity tracker packets
List<net.minecraft.network.Connection> disabledFlushes = new java.util.ArrayList<>(this.level.players.size());
this.chunkMap.tick();
}

View File

@ -107,8 +107,28 @@ index 088334869cb62797a1e1d1bbb6187f03189d852d..c245c1f4611f7273c8da629f774e0c64
return true;
} else {
if (this.haveTime()) {
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index ad352b4b67632f9984c4d10994a9acfe434a4996..df415f79dfd2ae9a709747b112022b38437daac4 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -1023,6 +1023,7 @@ public class ServerChunkCache extends ChunkSource {
iterator1 = shuffled.iterator();
}
+ int chunksTicked = 0; // Paper
try {
while (iterator1.hasNext()) {
LevelChunk chunk1 = iterator1.next();
@@ -1044,6 +1045,7 @@ public class ServerChunkCache extends ChunkSource {
if (this.level.shouldTickBlocksAt(chunkcoordintpair.toLong())) {
this.level.tickChunk(chunk1, k);
+ if ((chunksTicked++ & 1) == 0) net.minecraft.server.MinecraftServer.getServer().executeMidTickTasks(); // Paper
}
}
// Paper start - optimise chunk tick iteration
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 2459b8bfbb73310be66e354112c39e0ded1db036..f4b61f719c422028a5d8bc63c29f7a1c44fd2a6c 100644
index 427deff283b5e47e68966ad6af8823b282b20cf8..5fc77bd9a05d5fad7c49d15fe64ccab14ec37bc3 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -198,7 +198,9 @@ public class ServerLevel extends Level implements WorldGenLevel {

View File

@ -77,7 +77,7 @@ index bcf53ec07b8eeec7a88fb67e6fb908362e6f51b0..acc12307f61e1e055896b68fe16654c9
});
throw RunningOnDifferentThreadException.RUNNING_ON_DIFFERENT_THREAD;
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index f4b61f719c422028a5d8bc63c29f7a1c44fd2a6c..a1b4a9c92b2b602b2de97424eefbb0677a80dede 100644
index 5fc77bd9a05d5fad7c49d15fe64ccab14ec37bc3..495bcfdb63957363915ff0d5dbf538d467b9ec0f 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -973,7 +973,26 @@ public class ServerLevel extends Level implements WorldGenLevel {

View File

@ -19,7 +19,7 @@ index eada966d7f108a6081be7a848f5c1dfcb1eed676..a977f7483f37df473096b2234dc1308b
public static final Timing midTickChunkTasks = Timings.ofSafe("Mid Tick Chunk Tasks");
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index 9f0321179fb1d87b6e1b74e128955157983b0500..0d9f8180110b072e54d6c0f8c64df584b40776b9 100644
index b89596e3394698d91bb5720648916e01c251f52e..bcca5262f9658b5e8f30c389faf371b3857fd6a4 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -834,6 +834,7 @@ public class ServerChunkCache extends ChunkSource {

View File

@ -22,12 +22,12 @@ With this change I could get all 200 on at 0ms ping.
So in general this patch should reduce Netty I/O thread load.
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index 0d9f8180110b072e54d6c0f8c64df584b40776b9..758bb0fae0f9ba9672250e4a65c27f1175eab12d 100644
index bcca5262f9658b5e8f30c389faf371b3857fd6a4..aee92dc0d5b26fcd4df48169bdb02ed8b9cc1b4e 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -1053,7 +1053,24 @@ public class ServerChunkCache extends ChunkSource {
});
gameprofilerfiller.pop();
@@ -1070,7 +1070,24 @@ public class ServerChunkCache extends ChunkSource {
// Paper - no, iterating just ONCE is expensive enough! Don't do it TWICE! Code moved up
gameprofilerfiller.pop();
+ // Paper start - controlled flush for entity tracker packets
+ List<net.minecraft.network.Connection> disabledFlushes = new java.util.ArrayList<>(this.level.players.size());

View File

@ -71,7 +71,7 @@ index 0000000000000000000000000000000000000000..e8b4053babe46999980b926431254050
+ }
+}
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index a1b4a9c92b2b602b2de97424eefbb0677a80dede..0e8bfceeb2eae9b465e8810c67073e11ff882ea7 100644
index 495bcfdb63957363915ff0d5dbf538d467b9ec0f..17b01c1592ec2481d1ff444ff12dbc3790e09368 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -639,6 +639,10 @@ public class ServerLevel extends Level implements WorldGenLevel {
@ -264,7 +264,7 @@ index 6426d6c2c31ead49444fe56e2230266290fa79dd..881a2318aac72526e0451688af58c620
public void getAll(IntConsumer action) {
int i = 0;
diff --git a/src/main/java/net/minecraft/util/ZeroBitStorage.java b/src/main/java/net/minecraft/util/ZeroBitStorage.java
index 172e7a0761724cc802387e613258830a0defb04a..55c486349ddb295d4d4c6fa9214cdae90f851948 100644
index 9686ce7536c9924b1b2aced4f013f46759cbc72e..5d8e9bdf5538b19681f21949368d862fab8a89ad 100644
--- a/src/main/java/net/minecraft/util/ZeroBitStorage.java
+++ b/src/main/java/net/minecraft/util/ZeroBitStorage.java
@@ -46,6 +46,15 @@ public class ZeroBitStorage implements BitStorage {

View File

@ -92,7 +92,7 @@ index 9ab37d95b0dbd13dfe31b34b2a91c2a7bc7f6e64..27e9bd7dabb5f827b8baf126565d1efb
protected ChunkGenerator generator() {
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 0e8bfceeb2eae9b465e8810c67073e11ff882ea7..c525d8aed8f0671ad6cfef67cadaeb311a4d5e97 100644
index 17b01c1592ec2481d1ff444ff12dbc3790e09368..3ce8055f0fb8c5b605356e4e85ee1dbdcc73ba0e 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -396,6 +396,83 @@ public class ServerLevel extends Level implements WorldGenLevel {
@ -309,7 +309,7 @@ index 928025438af179711c42381fc3eaeac74cd20c59..c48d0773e7f1af4bc247d777eccc8a42
private static Boolean isValidSpawnPostitionForType(ServerLevel world, MobCategory group, StructureFeatureManager structureAccessor, ChunkGenerator chunkGenerator, MobSpawnSettings.SpawnerData spawnEntry, BlockPos.MutableBlockPos pos, double squaredDistance) { // Paper
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index b641bf5b2d02bfc1443a84af3cb98aff0dc7a575..c9cd9121e0ca7402c812e803ffd417c1887a4823 100644
index f73b3bb9b92fab3ca73d8561672797c1fd3e318b..c30204c5daac422eb009a447c1eb4fbc94a84318 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -235,6 +235,93 @@ public class LevelChunk extends ChunkAccess {

View File

@ -110,7 +110,7 @@ index 27e9bd7dabb5f827b8baf126565d1efb9eb2c2ef..a14effa7f8f56a27bccd4479baad82fc
}
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index c525d8aed8f0671ad6cfef67cadaeb311a4d5e97..0cf1c9203addc602f3ed0cf7a3c439b98bc73e9b 100644
index 3ce8055f0fb8c5b605356e4e85ee1dbdcc73ba0e..051c32968d5b134f6f83dd9ac7db7e608ec1a4f2 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1090,6 +1090,7 @@ public class ServerLevel extends Level implements WorldGenLevel {

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Use Velocity compression and cipher natives
diff --git a/build.gradle.kts b/build.gradle.kts
index a5e3868343f6dd0c483d59962b0aed301b973cc6..cd74406039704e5a880f00b9b60bb7b1dedc5398 100644
index 3381ac7c25323d662935c98aa444195c49cf4e8e..5678a9f8d2aa8a7afbc5729570ec297b12acf75d 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -44,6 +44,11 @@ dependencies {

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Fix merchant inventory not closing on entity removal
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 0cf1c9203addc602f3ed0cf7a3c439b98bc73e9b..f055d25394d20afb208e8612fb31d77af141876b 100644
index 051c32968d5b134f6f83dd9ac7db7e608ec1a4f2..e371ffb1f88e08883a1a2460260ff368c0cfe853 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -2440,6 +2440,11 @@ public class ServerLevel extends Level implements WorldGenLevel {

View File

@ -6,7 +6,7 @@ Subject: [PATCH] Don't respond to ServerboundCommandSuggestionPacket when
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 7b6cf326dfab9bd0b13dfc330d143d2efeea9aa1..3eba6962040f33b7b31b16c9de22d90f225710b4 100644
index d572a0f423844606a8e96eba1f7570d9d356077c..f4f075c678f30d375d15041860fcc5543eedc7fe 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -762,6 +762,11 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser

View File

@ -10,7 +10,7 @@ chunk bans via the large amount of NBT created by unstacking the items.
Fixes GH-5140 and GH-4748.
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index d549455e893a2e65fb6f4a529cc9685420190da9..6dc4c20464783c021104f5f20e76eca48323e81f 100644
index f0073bafac729f018ad3264f673c158c1ed5b0d7..ea67eb1099e6ec34426d80c95e9999f4aa8793b9 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -901,6 +901,11 @@ public class PaperWorldConfig {

View File

@ -81,7 +81,7 @@ index d2dd8b802ecea7fd2efe5f07fcef65c26e1adfbc..33a29890435d6065a2cc4f8e8bf8209c
@Override
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 8a74c1aa2add393f4706a7f943f0fd5d9f5175e1..40d55cade76d0e8f39f91a322bc8a821877efa2c 100644
index 81650be96a25f276c4df958dc4f339c75b39211e..25b787d1b22e495fb6756e4ee909776ed8699492 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -237,7 +237,7 @@ public abstract class PlayerList {

View File

@ -19,7 +19,7 @@ index ee53453440177537fc653ea156785d7591498614..5e3b7fb2e0b7608610555cd23e7ad25a
}
final Object val = config.get(key);
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 6dc4c20464783c021104f5f20e76eca48323e81f..21e502716f312849b5232d1a3c5c87dc76394fee 100644
index ea67eb1099e6ec34426d80c95e9999f4aa8793b9..8150330bc55a010c7d0f96421586226631eb72f7 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -946,6 +946,55 @@ public class PaperWorldConfig {

View File

@ -5,7 +5,7 @@ Subject: [PATCH] don't attempt to teleport dead entities
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index cd18e0eff4814e106b48118c8c6c43ccd66ac79d..3febcc7e88b74d4bdb45e633fdaa9d3313a6ae0b 100644
index 62b9abd299980f5e3cf711003dfbb90cf1687ae9..516015eb48900abaf0e2f47de4ffd10e9cf4d9a7 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -706,7 +706,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Call onRemove logic for breakNaturally
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
index 808bdd0e8d6b679c2eee87c3078a4c3dbcd08b8b..2da1609c42bc85f173ed56767933bcafd5f0422e 100644
index fcf2e5b0b07d2884b678b9c39b72cc7dc5518163..ca320ef8a28fe15b32197669419981c4c2fcafd9 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
@@ -516,8 +516,14 @@ public class CraftBlock implements Block {

View File

@ -4949,7 +4949,7 @@ index 7c5b3acd299c5b021bd20f17ff0b89c8208a6623..d29739c3a67e60741a06fb25bcaf7705
super(wrapped.getPos(), UpgradeData.EMPTY, wrapped.levelHeightAccessor, wrapped.getLevel().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), wrapped.getBlendingData());
this.wrapped = wrapped;
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index b39904f011d86f6ced80e4d3fb48c26ccfa7f828..b0e3c49989216dc886471ae84f7e05b01b9ae786 100644
index c30204c5daac422eb009a447c1eb4fbc94a84318..37ff1d911db531b6e51aa4234bcdffcce66722cf 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -100,6 +100,10 @@ public class LevelChunk extends ChunkAccess {

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Hide unnecessary itemmeta from clients
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index fd5927247e23878fd8bf6ab62a2eb477d07f4cc3..0544f03b65696fe9e972283254f7e51a98586072 100644
index 8150330bc55a010c7d0f96421586226631eb72f7..d71cd626bcbefc576f9c05b8885acc9fb2a33cd5 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -916,6 +916,13 @@ public class PaperWorldConfig {

View File

@ -4,27 +4,8 @@ Improve Server Thread Pool and Thread Priorities: mojang added a max thread coun
Use Vanilla Minecart Speeds: is this needed?
0467-Optimize-WorldBorder-collision-checks-and-air check first hunk that has been removed
Not sure where this needs to go, if anywhere
diff --git a/src/main/java/net/minecraft/world/phys/shapes/Shapes.java b/src/main/java/net/minecraft/world/phys/shapes/Shapes.java
index 48812329969b7192acd948db974bb77bb546f979..5b1e0ea40dea6c7d787699ed25160c8b75ab3bf3 100644
--- a/src/main/java/net/minecraft/world/phys/shapes/Shapes.java
+++ b/src/main/java/net/minecraft/world/phys/shapes/Shapes.java
@@ -237,7 +237,8 @@ public final class Shapes {
if (s < 3) {
mutableBlockPos.set(axisCycle, q, r, p);
- BlockState blockState = world.getBlockState(mutableBlockPos);
+ BlockState blockState = world.getTypeIfLoaded(mutableBlockPos); // Paper
+ if (blockState == null) return 0.0D; // Paper
if ((s != 1 || blockState.hasLargeCollisionShape()) && (s != 2 || blockState.is(Blocks.MOVING_PISTON))) {
initial = blockState.getCollisionShape(world, mutableBlockPos, context).collide(axis3, box.move((double)(-mutableBlockPos.getX()), (double)(-mutableBlockPos.getY()), (double)(-mutableBlockPos.getZ())), initial);
if (Math.abs(initial) < 1.0E-7D) {
check ChunkHolder#updateFutures async catcher
leaf: check mid tick chunk task diff in ServerChunkCache
optimize nearby player lookups - look at patch and updateranges diff in chunkmap (why is it in this patch)
GENERAL_AREA_MAP_ACCEPTABLE_SEARCH_RANGE_SQUARED is unused?