mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-12 01:41:05 +01:00
77a5779e24
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 2ec53f49 PR-1050: Fix empty result check for Complex Recipes 10671012 PR-1044: Add CrafterCraftEvent 4d87ffe0 Use correct method in JavaDoc ae5e5817 SPIGOT-7850: Add API for Bogged shear state 46b6d445 SPIGOT-7837: Support data pack banner patterns d5d0cefc Fix JavaDoc error b3c2b83d PR-1036: Add API for InventoryView derivatives 1fe2c75a SPIGOT-7809: Add ShieldMeta CraftBukkit Changes: 8ee6fd1b8 SPIGOT-7857: Improve ItemMeta block data deserialization 8f26c30c6 SPIGOT-7857: Fix spurious internal NBT tag when deserializing BlockStateMeta 759061b93 SPIGOT-7855: Fire does not spread or burn blocks 00fc9fb64 SPIGOT-7853: AnvilInventory#getRepairCost() always returns 0 7501e2e04 PR-1450: Add CrafterCraftEvent 8c51673e7 SPIGOT-5731: PortalCreateEvent#getEntity returns null for nether portals ignited by flint and steel d53d0d0b1 PR-1456: Fix inverted logic in CraftCrafterView#setSlotDisabled 682a678c8 SPIGOT-7850: Add API for Bogged shear state fccf5243a SPIGOT-7837: Support data pack banner patterns 9c3bd4390 PR-1431: Add API for InventoryView derivatives 0cc6acbc4 SPIGOT-7849: Fix FoodComponent serialize with "using-converts-to" using null 2c5474952 Don't rely on tags for CraftItemMetas 20d107e46 SPIGOT-7846: Fix ItemMeta for hanging signs 76f59e315 Remove redundant clone in Dropper InventoryMoveItemEvent e61a53d25 SPIGOT-7817: Call InventoryMoveItemEvent for Crafters 894682e2d SPIGOT-7839: Remove redundant Java version checks 2c12b2187 SPIGOT-7809: Add ShieldMeta and fix setting shield base colours Spigot Changes: fb8fb722 Rebuild patches 34bd42b7 SPIGOT-7835: Fix issue with custom hopper settings
296 lines
15 KiB
Diff
296 lines
15 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
Date: Thu, 26 Mar 2020 21:59:32 -0700
|
|
Subject: [PATCH] Detail more information in watchdog dumps
|
|
|
|
- Dump position, world, velocity, and uuid for currently ticking entities
|
|
- Dump player name, player uuid, position, and world for packet handling
|
|
|
|
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
|
|
index 90a2c61c42cba7e38f167eccdd7a951a947963c4..3e550f8e7cd4f4e16f499a8a2a4b95420270f07a 100644
|
|
--- a/src/main/java/net/minecraft/network/Connection.java
|
|
+++ b/src/main/java/net/minecraft/network/Connection.java
|
|
@@ -632,7 +632,13 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
|
if (!(this.packetListener instanceof net.minecraft.server.network.ServerLoginPacketListenerImpl loginPacketListener)
|
|
|| loginPacketListener.state != net.minecraft.server.network.ServerLoginPacketListenerImpl.State.VERIFYING
|
|
|| Connection.joinAttemptsThisTick++ < MAX_PER_TICK) {
|
|
+ // Paper start - detailed watchdog information
|
|
+ net.minecraft.network.protocol.PacketUtils.packetProcessing.push(this.packetListener);
|
|
+ try {
|
|
tickablepacketlistener.tick();
|
|
+ } finally {
|
|
+ net.minecraft.network.protocol.PacketUtils.packetProcessing.pop();
|
|
+ } // Paper end - detailed watchdog information
|
|
} // Paper end - Buffer joins to world
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/network/protocol/PacketUtils.java b/src/main/java/net/minecraft/network/protocol/PacketUtils.java
|
|
index d0d36a57ec4896bcb74970f8fb24d8f3e17db133..e2c24813f59c2fd075c740ac1842a38f20ed8554 100644
|
|
--- a/src/main/java/net/minecraft/network/protocol/PacketUtils.java
|
|
+++ b/src/main/java/net/minecraft/network/protocol/PacketUtils.java
|
|
@@ -20,6 +20,24 @@ public class PacketUtils {
|
|
|
|
private static final Logger LOGGER = LogUtils.getLogger();
|
|
|
|
+ // Paper start - detailed watchdog information
|
|
+ public static final java.util.concurrent.ConcurrentLinkedDeque<PacketListener> packetProcessing = new java.util.concurrent.ConcurrentLinkedDeque<>();
|
|
+ static final java.util.concurrent.atomic.AtomicLong totalMainThreadPacketsProcessed = new java.util.concurrent.atomic.AtomicLong();
|
|
+
|
|
+ public static long getTotalProcessedPackets() {
|
|
+ return totalMainThreadPacketsProcessed.get();
|
|
+ }
|
|
+
|
|
+ public static java.util.List<PacketListener> getCurrentPacketProcessors() {
|
|
+ java.util.List<PacketListener> ret = new java.util.ArrayList<>(4);
|
|
+ for (PacketListener listener : packetProcessing) {
|
|
+ ret.add(listener);
|
|
+ }
|
|
+
|
|
+ return ret;
|
|
+ }
|
|
+ // Paper end - detailed watchdog information
|
|
+
|
|
public PacketUtils() {}
|
|
|
|
public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T listener, ServerLevel world) throws RunningOnDifferentThreadException {
|
|
@@ -29,6 +47,8 @@ public class PacketUtils {
|
|
public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T listener, BlockableEventLoop<?> engine) throws RunningOnDifferentThreadException {
|
|
if (!engine.isSameThread()) {
|
|
engine.executeIfPossible(() -> {
|
|
+ packetProcessing.push(listener); // Paper - detailed watchdog information
|
|
+ try { // Paper - detailed watchdog information
|
|
if (listener instanceof ServerCommonPacketListenerImpl serverCommonPacketListener && serverCommonPacketListener.processedDisconnect) return; // CraftBukkit - Don't handle sync packets for kicked players
|
|
if (listener.shouldHandleMessage(packet)) {
|
|
co.aikar.timings.Timing timing = co.aikar.timings.MinecraftTimings.getPacketTiming(packet); // Paper - timings
|
|
@@ -48,6 +68,12 @@ public class PacketUtils {
|
|
} else {
|
|
PacketUtils.LOGGER.debug("Ignoring packet due to disconnection: {}", packet);
|
|
}
|
|
+ // Paper start - detailed watchdog information
|
|
+ } finally {
|
|
+ totalMainThreadPacketsProcessed.getAndIncrement();
|
|
+ packetProcessing.pop();
|
|
+ }
|
|
+ // Paper end - detailed watchdog information
|
|
|
|
});
|
|
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 415b7839544d269a562b2bceeaa416a1a89be96e..6d8a5c2b0d95828abbd99914d1d308522b89529f 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -1199,7 +1199,26 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
|
|
|
|
}
|
|
|
|
+ // Paper start - log detailed entity tick information
|
|
+ // TODO replace with varhandle
|
|
+ static final java.util.concurrent.atomic.AtomicReference<Entity> currentlyTickingEntity = new java.util.concurrent.atomic.AtomicReference<>();
|
|
+
|
|
+ public static List<Entity> getCurrentlyTickingEntities() {
|
|
+ Entity ticking = currentlyTickingEntity.get();
|
|
+ List<Entity> ret = java.util.Arrays.asList(ticking == null ? new Entity[0] : new Entity[] { ticking });
|
|
+
|
|
+ return ret;
|
|
+ }
|
|
+ // Paper end - log detailed entity tick information
|
|
+
|
|
public void tickNonPassenger(Entity entity) {
|
|
+ // Paper start - log detailed entity tick information
|
|
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread("Cannot tick an entity off-main");
|
|
+ try {
|
|
+ if (currentlyTickingEntity.get() == null) {
|
|
+ currentlyTickingEntity.lazySet(entity);
|
|
+ }
|
|
+ // Paper end - log detailed entity tick information
|
|
++TimingHistory.entityTicks; // Paper - timings
|
|
// Spigot start
|
|
co.aikar.timings.Timing timer; // Paper
|
|
@@ -1239,7 +1258,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
|
|
this.tickPassenger(entity, entity1);
|
|
}
|
|
// } finally { timer.stopTiming(); } // Paper - timings - move up
|
|
-
|
|
+ // Paper start - log detailed entity tick information
|
|
+ } finally {
|
|
+ if (currentlyTickingEntity.get() == entity) {
|
|
+ currentlyTickingEntity.lazySet(null);
|
|
+ }
|
|
+ }
|
|
+ // Paper end - log detailed entity tick information
|
|
}
|
|
|
|
private void tickPassenger(Entity vehicle, Entity passenger) {
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index 935f88542a10360ec21dfced9272313fcf1354ab..490ee48346395fcbaf2eb0151e9248f18974fea6 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -1086,8 +1086,43 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
return this.onGround;
|
|
}
|
|
|
|
+ // Paper start - detailed watchdog information
|
|
+ public final Object posLock = new Object(); // Paper - log detailed entity tick information
|
|
+
|
|
+ private Vec3 moveVector;
|
|
+ private double moveStartX;
|
|
+ private double moveStartY;
|
|
+ private double moveStartZ;
|
|
+
|
|
+ public final Vec3 getMoveVector() {
|
|
+ return this.moveVector;
|
|
+ }
|
|
+
|
|
+ public final double getMoveStartX() {
|
|
+ return this.moveStartX;
|
|
+ }
|
|
+
|
|
+ public final double getMoveStartY() {
|
|
+ return this.moveStartY;
|
|
+ }
|
|
+
|
|
+ public final double getMoveStartZ() {
|
|
+ return this.moveStartZ;
|
|
+ }
|
|
+ // Paper end - detailed watchdog information
|
|
+
|
|
public void move(MoverType movementType, Vec3 movement) {
|
|
final Vec3 originalMovement = movement; // Paper - Expose pre-collision velocity
|
|
+ // Paper start - detailed watchdog information
|
|
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread("Cannot move an entity off-main");
|
|
+ synchronized (this.posLock) {
|
|
+ this.moveStartX = this.getX();
|
|
+ this.moveStartY = this.getY();
|
|
+ this.moveStartZ = this.getZ();
|
|
+ this.moveVector = movement;
|
|
+ }
|
|
+ try {
|
|
+ // Paper end - detailed watchdog information
|
|
if (this.noPhysics) {
|
|
this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z);
|
|
} else {
|
|
@@ -1257,6 +1292,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
this.level().getProfiler().pop();
|
|
}
|
|
}
|
|
+ // Paper start - detailed watchdog information
|
|
+ } finally {
|
|
+ synchronized (this.posLock) { // Paper
|
|
+ this.moveVector = null;
|
|
+ } // Paper
|
|
+ }
|
|
+ // Paper end - detailed watchdog information
|
|
}
|
|
|
|
private boolean isStateClimbable(BlockState state) {
|
|
@@ -4550,7 +4592,9 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
}
|
|
|
|
public void setDeltaMovement(Vec3 velocity) {
|
|
+ synchronized (this.posLock) { // Paper
|
|
this.deltaMovement = velocity;
|
|
+ } // Paper
|
|
}
|
|
|
|
public void addDeltaMovement(Vec3 velocity) {
|
|
@@ -4656,7 +4700,9 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
}
|
|
// Paper end - Fix MC-4
|
|
if (this.position.x != x || this.position.y != y || this.position.z != z) {
|
|
+ synchronized (this.posLock) { // Paper
|
|
this.position = new Vec3(x, y, z);
|
|
+ } // Paper
|
|
int i = Mth.floor(x);
|
|
int j = Mth.floor(y);
|
|
int k = Mth.floor(z);
|
|
diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java
|
|
index c9e17225bc52fe5e7b2dc0908db225a86c6e94d1..f7a4fee9bb25ff256dc2e5ea26bfbceca6a49167 100644
|
|
--- a/src/main/java/org/spigotmc/WatchdogThread.java
|
|
+++ b/src/main/java/org/spigotmc/WatchdogThread.java
|
|
@@ -22,6 +22,78 @@ public class WatchdogThread extends ca.spottedleaf.moonrise.common.util.TickThre
|
|
private volatile long lastTick;
|
|
private volatile boolean stopping;
|
|
|
|
+ // Paper start - log detailed tick information
|
|
+ private void dumpEntity(net.minecraft.world.entity.Entity entity) {
|
|
+ Logger log = Bukkit.getServer().getLogger();
|
|
+ double posX, posY, posZ;
|
|
+ net.minecraft.world.phys.Vec3 mot;
|
|
+ double moveStartX, moveStartY, moveStartZ;
|
|
+ net.minecraft.world.phys.Vec3 moveVec;
|
|
+ synchronized (entity.posLock) {
|
|
+ posX = entity.getX();
|
|
+ posY = entity.getY();
|
|
+ posZ = entity.getZ();
|
|
+ mot = entity.getDeltaMovement();
|
|
+ moveStartX = entity.getMoveStartX();
|
|
+ moveStartY = entity.getMoveStartY();
|
|
+ moveStartZ = entity.getMoveStartZ();
|
|
+ moveVec = entity.getMoveVector();
|
|
+ }
|
|
+
|
|
+ String entityType = net.minecraft.world.entity.EntityType.getKey(entity.getType()).toString();
|
|
+ java.util.UUID entityUUID = entity.getUUID();
|
|
+ net.minecraft.world.level.Level world = entity.level();
|
|
+
|
|
+ log.log(Level.SEVERE, "Ticking entity: " + entityType + ", entity class: " + entity.getClass().getName());
|
|
+ log.log(Level.SEVERE, "Entity status: removed: " + entity.isRemoved() + ", valid: " + entity.valid + ", alive: " + entity.isAlive() + ", is passenger: " + entity.isPassenger());
|
|
+ log.log(Level.SEVERE, "Entity UUID: " + entityUUID);
|
|
+ log.log(Level.SEVERE, "Position: world: '" + (world == null ? "unknown world?" : world.getWorld().getName()) + "' at location (" + posX + ", " + posY + ", " + posZ + ")");
|
|
+ log.log(Level.SEVERE, "Velocity: " + (mot == null ? "unknown velocity" : mot.toString()) + " (in blocks per tick)");
|
|
+ log.log(Level.SEVERE, "Entity AABB: " + entity.getBoundingBox());
|
|
+ if (moveVec != null) {
|
|
+ log.log(Level.SEVERE, "Move call information: ");
|
|
+ log.log(Level.SEVERE, "Start position: (" + moveStartX + ", " + moveStartY + ", " + moveStartZ + ")");
|
|
+ log.log(Level.SEVERE, "Move vector: " + moveVec.toString());
|
|
+ }
|
|
+ }
|
|
+
|
|
+ private void dumpTickingInfo() {
|
|
+ Logger log = Bukkit.getServer().getLogger();
|
|
+
|
|
+ // ticking entities
|
|
+ for (net.minecraft.world.entity.Entity entity : net.minecraft.server.level.ServerLevel.getCurrentlyTickingEntities()) {
|
|
+ this.dumpEntity(entity);
|
|
+ net.minecraft.world.entity.Entity vehicle = entity.getVehicle();
|
|
+ if (vehicle != null) {
|
|
+ log.log(Level.SEVERE, "Detailing vehicle for above entity:");
|
|
+ this.dumpEntity(vehicle);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ // packet processors
|
|
+ for (net.minecraft.network.PacketListener packetListener : net.minecraft.network.protocol.PacketUtils.getCurrentPacketProcessors()) {
|
|
+ if (packetListener instanceof net.minecraft.server.network.ServerGamePacketListenerImpl) {
|
|
+ net.minecraft.server.level.ServerPlayer player = ((net.minecraft.server.network.ServerGamePacketListenerImpl)packetListener).player;
|
|
+ long totalPackets = net.minecraft.network.protocol.PacketUtils.getTotalProcessedPackets();
|
|
+ if (player == null) {
|
|
+ log.log(Level.SEVERE, "Handling packet for player connection or ticking player connection (null player): " + packetListener);
|
|
+ log.log(Level.SEVERE, "Total packets processed on the main thread for all players: " + totalPackets);
|
|
+ } else {
|
|
+ this.dumpEntity(player);
|
|
+ net.minecraft.world.entity.Entity vehicle = player.getVehicle();
|
|
+ if (vehicle != null) {
|
|
+ log.log(Level.SEVERE, "Detailing vehicle for above entity:");
|
|
+ this.dumpEntity(vehicle);
|
|
+ }
|
|
+ log.log(Level.SEVERE, "Total packets processed on the main thread for all players: " + totalPackets);
|
|
+ }
|
|
+ } else {
|
|
+ log.log(Level.SEVERE, "Handling packet for connection: " + packetListener);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // Paper end - log detailed tick information
|
|
+
|
|
private WatchdogThread(long timeoutTime, boolean restart)
|
|
{
|
|
super( "Paper Watchdog Thread" );
|
|
@@ -119,6 +191,7 @@ public class WatchdogThread extends ca.spottedleaf.moonrise.common.util.TickThre
|
|
log.log( Level.SEVERE, "------------------------------" );
|
|
log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Paper!):" ); // Paper
|
|
ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler.dumpAllChunkLoadInfo(MinecraftServer.getServer(), isLongTimeout); // Paper - rewrite chunk system
|
|
+ this.dumpTickingInfo(); // Paper - log detailed tick information
|
|
WatchdogThread.dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( MinecraftServer.getServer().serverThread.getId(), Integer.MAX_VALUE ), log );
|
|
log.log( Level.SEVERE, "------------------------------" );
|
|
//
|