Added missing mappings (#6810)

This commit is contained in:
Jake Potrebic 2021-11-04 07:08:53 -07:00 committed by GitHub
parent 485d15ff8f
commit 09d50a9277
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 115 additions and 38 deletions

View file

@ -6,7 +6,7 @@ Subject: [PATCH] Optimize the advancement data player iteration to be O(N)
diff --git a/src/main/java/net/minecraft/server/PlayerAdvancements.java b/src/main/java/net/minecraft/server/PlayerAdvancements.java
index 3d82f984648605d58fae3c57f145d0da8a2ae225..ce02a467c1c3434f2cdb112ceb9794196069a820 100644
index 3d82f984648605d58fae3c57f145d0da8a2ae225..bd858a9da2f2442be85f36bb2de0dac46d0c68d7 100644
--- a/src/main/java/net/minecraft/server/PlayerAdvancements.java
+++ b/src/main/java/net/minecraft/server/PlayerAdvancements.java
@@ -437,6 +437,16 @@ public class PlayerAdvancements {
@ -14,14 +14,14 @@ index 3d82f984648605d58fae3c57f145d0da8a2ae225..ce02a467c1c3434f2cdb112ceb979419
private void ensureVisibility(Advancement advancement) {
+ // Paper start
+ e(advancement, IterationEntryPoint.ROOT);
+ ensureVisibility(advancement, IterationEntryPoint.ROOT);
+ }
+ private enum IterationEntryPoint {
+ ROOT,
+ ITERATOR,
+ PARENT_OF_ITERATOR
+ }
+ private void e(Advancement advancement, IterationEntryPoint entryPoint) {
+ private void ensureVisibility(Advancement advancement, IterationEntryPoint entryPoint) {
+ // Paper end
boolean flag = this.shouldBeVisible(advancement);
boolean flag1 = this.visible.contains(advancement);
@ -33,7 +33,7 @@ index 3d82f984648605d58fae3c57f145d0da8a2ae225..ce02a467c1c3434f2cdb112ceb979419
- this.ensureVisibility(advancement.getParent());
+ // Paper start - If we're not coming from an iterator consider this to be a root entry, otherwise
+ // market that we're entering from the parent of an iterator.
+ this.e(advancement.getParent(), entryPoint == IterationEntryPoint.ITERATOR ? IterationEntryPoint.PARENT_OF_ITERATOR : IterationEntryPoint.ROOT);
+ this.ensureVisibility(advancement.getParent(), entryPoint == IterationEntryPoint.ITERATOR ? IterationEntryPoint.PARENT_OF_ITERATOR : IterationEntryPoint.ROOT);
}
+ // If this is true, we've went through a child iteration, entered the parent, processed the parent
@ -48,7 +48,7 @@ index 3d82f984648605d58fae3c57f145d0da8a2ae225..ce02a467c1c3434f2cdb112ceb979419
Advancement advancement1 = (Advancement) iterator.next();
- this.ensureVisibility(advancement1);
+ this.e(advancement1, IterationEntryPoint.ITERATOR); // Paper - Mark this call as being from iteration
+ this.ensureVisibility(advancement1, IterationEntryPoint.ITERATOR); // Paper - Mark this call as being from iteration
}
}

View file

@ -9,7 +9,7 @@ This patch will be used to optimise out flush calls in later
patches.
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index 9d09ec3b127e3440bef6b248578dec109407f9ff..103657ad936f1a75ffbb92ca5eafb816e977e363 100644
index c327609fdb7641e4dc5fb58d97903fa666eac24d..0b47144cb8ad72efebf10e163f5b442995ef213e 100644
--- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java
@@ -94,6 +94,39 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
@ -80,22 +80,22 @@ index 9d09ec3b127e3440bef6b248578dec109407f9ff..103657ad936f1a75ffbb92ca5eafb816
}
if (this.channel.eventLoop().inEventLoop()) {
- this.a(packet, callback, enumprotocol, enumprotocol1);
+ this.a(packet, callback, enumprotocol, enumprotocol1, flush); // Paper - add flush parameter
- this.doSendPacket(packet, callback, enumprotocol, enumprotocol1);
+ this.doSendPacket(packet, callback, enumprotocol, enumprotocol1, flush); // Paper - add flush parameter
} else {
this.channel.eventLoop().execute(() -> {
- this.a(packet, callback, enumprotocol, enumprotocol1);
+ this.a(packet, callback, enumprotocol, enumprotocol1, flush); // Paper - add flush parameter
- this.doSendPacket(packet, callback, enumprotocol, enumprotocol1);
+ this.doSendPacket(packet, callback, enumprotocol, enumprotocol1, flush); // Paper - add flush parameter
});
}
}
private void a(Packet<?> packet, @Nullable GenericFutureListener<? extends Future<? super Void>> genericfuturelistener, ConnectionProtocol enumprotocol, ConnectionProtocol enumprotocol1) {
private void doSendPacket(Packet<?> packet, @Nullable GenericFutureListener<? extends Future<? super Void>> genericfuturelistener, ConnectionProtocol enumprotocol, ConnectionProtocol enumprotocol1) {
+ // Paper start - add flush parameter
+ this.a(packet, genericfuturelistener, enumprotocol, enumprotocol1, true);
+ this.doSendPacket(packet, genericfuturelistener, enumprotocol, enumprotocol1, true);
+ }
+ private void a(Packet<?> packet, @Nullable GenericFutureListener<? extends Future<? super Void>> genericfuturelistener, ConnectionProtocol enumprotocol, ConnectionProtocol enumprotocol1, boolean flush) {
+ private void doSendPacket(Packet<?> packet, @Nullable GenericFutureListener<? extends Future<? super Void>> genericfuturelistener, ConnectionProtocol enumprotocol, ConnectionProtocol enumprotocol1, boolean flush) {
+ // Paper end - add flush parameter
if (enumprotocol != enumprotocol1) {
this.setProtocol(enumprotocol);

View file

@ -20,7 +20,7 @@ up on this optimisation before he came along.
Locally this patch drops the entity tracker tick by a full 1.5x.
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index 73457ae24ba6f605dd831a870499f1a990570e53..0dae504f49a4a3c66a01eb03896833a010cd5821 100644
index 300cd4d2861c7f155cc6a5bb5a0c47b0b77ff240..7c66d5d51efd3ec55f5170cf828db22e26131517 100644
--- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java
@@ -49,6 +49,8 @@ import org.apache.logging.log4j.Logger;
@ -34,20 +34,20 @@ index 73457ae24ba6f605dd831a870499f1a990570e53..0dae504f49a4a3c66a01eb03896833a0
private static final float AVERAGE_PACKETS_SMOOTHING = 0.75F;
@@ -409,9 +411,19 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
if (this.channel.eventLoop().inEventLoop()) {
this.a(packet, callback, enumprotocol, enumprotocol1, flush); // Paper - add flush parameter
this.doSendPacket(packet, callback, enumprotocol, enumprotocol1, flush); // Paper - add flush parameter
} else {
+ // Paper start - optimise packets that are not flushed
+ // note: since the type is not dynamic here, we need to actually copy the old executor code
+ // into two branches. On conflict, just re-copy - no changes were made inside the executor code.
+ if (!flush) {
+ AbstractEventExecutor.LazyRunnable run = () -> {
+ this.a(packet, callback, enumprotocol, enumprotocol1, flush); // Paper - add flush parameter
+ this.doSendPacket(packet, callback, enumprotocol, enumprotocol1, flush); // Paper - add flush parameter
+ };
+ this.channel.eventLoop().execute(run);
+ } else { // Paper end - optimise packets that are not flushed
this.channel.eventLoop().execute(() -> {
- this.a(packet, callback, enumprotocol, enumprotocol1, flush); // Paper - add flush parameter
+ this.a(packet, callback, enumprotocol, enumprotocol1, flush); // Paper - add flush parameter // Paper - diff on change
- this.doSendPacket(packet, callback, enumprotocol, enumprotocol1, flush); // Paper - add flush parameter
+ this.doSendPacket(packet, callback, enumprotocol, enumprotocol1, flush); // Paper - add flush parameter // Paper - diff on change
});
+ } // Paper
}

View file

@ -8,7 +8,7 @@ Now in 1.17, this state is _even more_ critical than it was before,
so these must exist to catch stupid plugins.
diff --git a/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java b/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
index ea6d16d36cc98c0de5ad9d8faa8cbd8984fb309d..8634cf852d7ecb70c7bac6ad7f606aed1347f61d 100644
index fe5739c0949636343ea68e403aa5f4bef89e9d9f..394de90cc25179cd7576af9a08214b0d4ad53795 100644
--- a/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
+++ b/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
@@ -134,6 +134,7 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
@ -59,14 +59,14 @@ index ea6d16d36cc98c0de5ad9d8faa8cbd8984fb309d..8634cf852d7ecb70c7bac6ad7f606aed
long i = chunkPos.toLong();
if (trackingStatus == Visibility.HIDDEN) {
@@ -291,6 +298,7 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
private boolean a(long i, Consumer<T> consumer, boolean callEvent) {
@@ -292,6 +299,7 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
private boolean storeChunkSections(long chunkPos, Consumer<T> action, boolean callEvent) {
// CraftBukkit end
PersistentEntitySectionManager.ChunkLoadStatus persistententitysectionmanager_b = (PersistentEntitySectionManager.ChunkLoadStatus) this.chunkLoadStatuses.get(chunkPos);
+ org.spigotmc.AsyncCatcher.catchOp("Entity chunk save"); // Paper
PersistentEntitySectionManager.ChunkLoadStatus persistententitysectionmanager_b = (PersistentEntitySectionManager.ChunkLoadStatus) this.chunkLoadStatuses.get(i);
if (persistententitysectionmanager_b == PersistentEntitySectionManager.ChunkLoadStatus.PENDING) {
return false;
@@ -320,6 +328,7 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
}
@ -75,14 +75,14 @@ index ea6d16d36cc98c0de5ad9d8faa8cbd8984fb309d..8634cf852d7ecb70c7bac6ad7f606aed
this.chunkLoadStatuses.put(chunkPos, PersistentEntitySectionManager.ChunkLoadStatus.PENDING);
ChunkPos chunkcoordintpair = new ChunkPos(chunkPos);
CompletableFuture completablefuture = this.permanentStorage.loadEntities(chunkcoordintpair);
@@ -333,6 +342,7 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
}
@@ -334,6 +343,7 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
private boolean processChunkUnload(long chunkPos) {
boolean flag = this.storeChunkSections(chunkPos, (entityaccess) -> {
+ org.spigotmc.AsyncCatcher.catchOp("Entity chunk unload process"); // Paper
boolean flag = this.a(chunkPos, (entityaccess) -> {
entityaccess.getPassengersAndSelf().forEach(this::unloadEntity);
}, true); // CraftBukkit - add boolean for event call
@@ -357,6 +367,7 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
}