diff --git a/patches/server/0016-Fix-MC-117075-TE-Unload-Lag-Spike.patch b/patches/server/0016-Fix-MC-117075-TE-Unload-Lag-Spike.patch index ccebe35..25f1383 100644 --- a/patches/server/0016-Fix-MC-117075-TE-Unload-Lag-Spike.patch +++ b/patches/server/0016-Fix-MC-117075-TE-Unload-Lag-Spike.patch @@ -8,7 +8,7 @@ We replaced the `blockEntityTickers` list with a custom list based on fastutil's This is WAY FASTER than using `removeAll` with a list of entries to be removed, because we don't need to calculate the identity of each block entity to be removed, and we can jump directly to where the search should begin, giving a performance boost for small removals (because we don't need to loop thru the entire list to find what element should be removed) and a performance boost for big removals (no need to calculate the identity of each block entity). diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index ddb618fce875b1a337b139c9c47433453654017b..36c1cc48e6c2541d1218db0560ed7b315ce8067d 100644 +index ddb618fce875b1a337b139c9c47433453654017b..f50a66841fd8c798cd881612be302c292afcfa65 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -117,7 +117,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -25,7 +25,7 @@ index ddb618fce875b1a337b139c9c47433453654017b..36c1cc48e6c2541d1218db0560ed7b31 this.getCraftServer().getLogger().severe("Spigot has detected a null entity and has removed it, preventing a crash"); tilesThisCycle--; - this.blockEntityTickers.remove(this.tileTickPosition--); -+ blockEntityTickers.markAsRemoved(this.tileTickPosition); // this.blockEntityTickers.remove(this.tileTickPosition--); // SparklyPaper - optimize block entity removals ++ this.blockEntityTickers.markAsRemoved(this.tileTickPosition); // this.blockEntityTickers.remove(this.tileTickPosition--); // SparklyPaper - optimize block entity removals continue; } // Spigot end @@ -34,7 +34,7 @@ index ddb618fce875b1a337b139c9c47433453654017b..36c1cc48e6c2541d1218db0560ed7b31 // Spigot start tilesThisCycle--; - this.blockEntityTickers.remove(this.tileTickPosition--); -+ blockEntityTickers.markAsRemoved(this.tileTickPosition); // this.blockEntityTickers.remove(this.tileTickPosition--); // SparklyPaper - optimize block entity removals ++ this.blockEntityTickers.markAsRemoved(this.tileTickPosition); // this.blockEntityTickers.remove(this.tileTickPosition--); // SparklyPaper - optimize block entity removals // Spigot end } else if (this.shouldTickBlocksAt(tickingblockentity.getPos())) { tickingblockentity.tick(); @@ -43,7 +43,7 @@ index ddb618fce875b1a337b139c9c47433453654017b..36c1cc48e6c2541d1218db0560ed7b31 } } - -+ blockEntityTickers.removeMarkedEntries(); // SparklyPaper - optimize block entity removals ++ this.blockEntityTickers.removeMarkedEntries(); // SparklyPaper - optimize block entity removals this.timings.tileEntityTick.stopTiming(); // Spigot this.tickingBlockEntities = false; co.aikar.timings.TimingHistory.tileEntityTicks += this.blockEntityTickers.size(); // Paper diff --git a/patches/server/0017-Optimize-tickBlockEntities.patch b/patches/server/0017-Optimize-tickBlockEntities.patch index e6ba6c9..fa49e67 100644 --- a/patches/server/0017-Optimize-tickBlockEntities.patch +++ b/patches/server/0017-Optimize-tickBlockEntities.patch @@ -12,7 +12,7 @@ But here's the thing: We don't care if we have a small performance penalty if th And finally, we also cache the chunk's coordinate key when creating the block entity, which is actually "free" because we just reuse the already cached chunk coordinate key from the chunk! diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 36c1cc48e6c2541d1218db0560ed7b315ce8067d..9c2ce199d486ac143843c5a1492da14f8bdcdfce 100644 +index f50a66841fd8c798cd881612be302c292afcfa65..6048e9ed03b633eb545a82a506e5033c61d8176f 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -1270,6 +1270,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -28,7 +28,7 @@ index 36c1cc48e6c2541d1218db0560ed7b315ce8067d..9c2ce199d486ac143843c5a1492da14f TickingBlockEntity tickingblockentity = (TickingBlockEntity) this.blockEntityTickers.get(this.tileTickPosition); @@ -1287,13 +1291,25 @@ public abstract class Level implements LevelAccessor, AutoCloseable { tilesThisCycle--; - blockEntityTickers.markAsRemoved(this.tileTickPosition); // this.blockEntityTickers.remove(this.tileTickPosition--); // SparklyPaper - optimize block entity removals + this.blockEntityTickers.markAsRemoved(this.tileTickPosition); // this.blockEntityTickers.remove(this.tileTickPosition--); // SparklyPaper - optimize block entity removals // Spigot end - } else if (this.shouldTickBlocksAt(tickingblockentity.getPos())) { + // } else if (this.shouldTickBlocksAt(tickingblockentity.getPos())) { // SparklyPaper start - optimize tickBlockEntities @@ -52,7 +52,7 @@ index 36c1cc48e6c2541d1218db0560ed7b315ce8067d..9c2ce199d486ac143843c5a1492da14f + } // SparklyPaper end } } - blockEntityTickers.removeMarkedEntries(); // SparklyPaper - optimize block entity removals + this.blockEntityTickers.removeMarkedEntries(); // SparklyPaper - optimize block entity removals diff --git a/src/main/java/net/minecraft/world/level/block/entity/TickingBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/TickingBlockEntity.java index 28e3b73507b988f7234cbf29c4024c88180d0aef..427cf73383155c52bca8fb4b32f43029ff619833 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/TickingBlockEntity.java