mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
223 lines
10 KiB
Diff
223 lines
10 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/io/papermc/paper/FeatureHooks.java b/io/papermc/paper/FeatureHooks.java
|
|
index 460bb584db04b582f3297ae419183f430aff1ec0..c2d2bfa3c18daf27c163e5d11e8cea1f31b86c0a 100644
|
|
--- a/io/papermc/paper/FeatureHooks.java
|
|
+++ b/io/papermc/paper/FeatureHooks.java
|
|
@@ -93,9 +93,6 @@ public final class FeatureHooks {
|
|
ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler.dumpAllChunkLoadInfo(server, isLongTimeout); // Paper - rewrite chunk system
|
|
}
|
|
|
|
- private static void dumpEntity(final Entity entity) {
|
|
- }
|
|
-
|
|
public static org.bukkit.entity.Entity[] getChunkEntities(net.minecraft.server.level.ServerLevel world, int chunkX, int chunkZ) {
|
|
return world.getChunkEntities(chunkX, chunkZ); // Paper - rewrite chunk system
|
|
}
|
|
@@ -184,4 +181,4 @@ public final class FeatureHooks {
|
|
((ca.spottedleaf.moonrise.patches.chunk_system.player.ChunkSystemServerPlayer)player).moonrise$getViewDistanceHolder().setSendViewDistance(distance); // Paper - rewrite chunk system
|
|
}
|
|
|
|
-}
|
|
\ No newline at end of file
|
|
+}
|
|
diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java
|
|
index bfdc637a750602c00919422ca0e3943ba34db832..208efae06c7c44f220d4192219a86ec55c98a2fe 100644
|
|
--- a/net/minecraft/network/Connection.java
|
|
+++ b/net/minecraft/network/Connection.java
|
|
@@ -601,7 +601,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/net/minecraft/network/protocol/PacketUtils.java b/net/minecraft/network/protocol/PacketUtils.java
|
|
index e65c62dbe4c1560ae153e4c4344e9194c783a2f4..4535858701b2bb232b9d2feb2af6551526232ddc 100644
|
|
--- a/net/minecraft/network/protocol/PacketUtils.java
|
|
+++ b/net/minecraft/network/protocol/PacketUtils.java
|
|
@@ -21,6 +21,8 @@ public class PacketUtils {
|
|
public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T processor, BlockableEventLoop<?> executor) throws RunningOnDifferentThreadException {
|
|
if (!executor.isSameThread()) {
|
|
executor.executeIfPossible(() -> {
|
|
+ packetProcessing.push(processor); // Paper - detailed watchdog information
|
|
+ try { // Paper - detailed watchdog information
|
|
if (processor instanceof net.minecraft.server.network.ServerCommonPacketListenerImpl serverCommonPacketListener && serverCommonPacketListener.processedDisconnect) return; // Paper - Don't handle sync packets for kicked players
|
|
if (processor.shouldHandleMessage(packet)) {
|
|
try {
|
|
@@ -35,6 +37,12 @@ public class PacketUtils {
|
|
} else {
|
|
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;
|
|
}
|
|
@@ -61,4 +69,22 @@ public class PacketUtils {
|
|
|
|
packetListener.fillCrashReport(crashReport);
|
|
}
|
|
+
|
|
+ // 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> listeners = new java.util.ArrayList<>(4);
|
|
+ for (PacketListener listener : packetProcessing) {
|
|
+ listeners.add(listener);
|
|
+ }
|
|
+
|
|
+ return listeners;
|
|
+ }
|
|
+ // Paper end - detailed watchdog information
|
|
}
|
|
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
|
index 131ebdaec9ff09635689001e3b85bbe5845fbf98..9caa06f09409d36abf9e0a770ba004f4049e8e09 100644
|
|
--- a/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/net/minecraft/server/level/ServerLevel.java
|
|
@@ -1239,7 +1239,26 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
|
|
}
|
|
|
|
+ // 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
|
|
entity.setOldPosAndRot();
|
|
ProfilerFiller profilerFiller = Profiler.get();
|
|
entity.tickCount++;
|
|
@@ -1255,6 +1274,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
for (Entity entity1 : entity.getPassengers()) {
|
|
this.tickPassenger(entity, entity1, isActive); // Paper - EAR 2
|
|
}
|
|
+ // 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 ridingEntity, Entity passengerEntity, final boolean isActive) { // Paper - EAR 2
|
|
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
|
index 3fd7f6bcdeff271a9843b2f2454f92d92069f539..3cefe3de62e3d6af7b514eb2f3df8e63c5aa5c1f 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -1062,8 +1062,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 type, 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 {
|
|
@@ -1181,6 +1216,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
profilerFiller.pop();
|
|
}
|
|
}
|
|
+ // Paper start - detailed watchdog information
|
|
+ } finally {
|
|
+ synchronized (this.posLock) { // Paper
|
|
+ this.moveVector = null;
|
|
+ } // Paper
|
|
+ }
|
|
+ // Paper end - detailed watchdog information
|
|
}
|
|
|
|
private void applyMovementEmissionAndPlaySound(Entity.MovementEmission movementEmission, Vec3 movement, BlockPos pos, BlockState state) {
|
|
@@ -4643,7 +4685,9 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
}
|
|
|
|
public void setDeltaMovement(Vec3 deltaMovement) {
|
|
+ synchronized (this.posLock) { // Paper
|
|
this.deltaMovement = deltaMovement;
|
|
+ } // Paper
|
|
}
|
|
|
|
public void addDeltaMovement(Vec3 addend) {
|
|
@@ -4749,7 +4793,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 floor = Mth.floor(x);
|
|
int floor1 = Mth.floor(y);
|
|
int floor2 = Mth.floor(z);
|