Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-15 19:10:09 +01:00
f37381ea8a
Removes synchronization from sending packets Makes normal packet sends no longer need to be wrapped and queued like it use to work. Adds more packet queue immunities on top of keep alive to let the following scenarios go out without delay: - Keep Alive - Chat - Kick - All of the packets during the Player Joined World event Hoping that latter one helps join timeout issues more too for slow connections. Removes processing packet queue off of main thread - for the few cases where it is allowed, order is not necessary nor should it even be happening concurrently in first place (handshaking/login/status) Ensures packets sent asynchronously are dispatched on main thread This helps ensure safety for ProtocolLib as packet listeners are commonly accessing world state. This will allow you to schedule a packet to be sent async, but itll be dispatched sync for packet listeners to process. This should solve some deadlock risks This may provide a decent performance improvement because thread synchronization incurs a cache reset so by avoiding ever entering a synchronized block, we get to avoid that, and packet sending is a really hot activity.
57 Zeilen
2.2 KiB
Diff
57 Zeilen
2.2 KiB
Diff
From ed15355ebb8c3aeb9299598a9873c1fc7aee586b Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Thu, 3 Mar 2016 02:02:07 -0600
|
|
Subject: [PATCH] Optimize Pathfinding
|
|
|
|
Prevents pathfinding from spamming failures for things such as
|
|
arrow attacks.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/NavigationAbstract.java b/src/main/java/net/minecraft/server/NavigationAbstract.java
|
|
index f06764973fe..dc32107ec32 100644
|
|
--- a/src/main/java/net/minecraft/server/NavigationAbstract.java
|
|
+++ b/src/main/java/net/minecraft/server/NavigationAbstract.java
|
|
@@ -11,7 +11,7 @@ public abstract class NavigationAbstract {
|
|
protected final EntityInsentient a; public Entity getEntity() { return a; } // Paper - OBFHELPER
|
|
protected final World b;
|
|
@Nullable
|
|
- protected PathEntity c;
|
|
+ protected PathEntity c; protected final PathEntity getCurrentPath() { return this.c; } // Paper - OBFHELPER
|
|
protected double d;
|
|
private final AttributeInstance p;
|
|
protected int e;
|
|
@@ -158,10 +158,30 @@ public abstract class NavigationAbstract {
|
|
return this.a(this.a(d0, d1, d2, 1), d3);
|
|
}
|
|
|
|
+ // Paper start - optimise pathfinding
|
|
+ private int lastFailure = 0;
|
|
+ private int pathfindFailures = 0;
|
|
+ // Paper end
|
|
+
|
|
public boolean a(Entity entity, double d0) {
|
|
+ // Paper start - Pathfinding optimizations
|
|
+ if (this.pathfindFailures > 10 && this.getCurrentPath() == null && MinecraftServer.currentTick < this.lastFailure + 40) {
|
|
+ return false;
|
|
+ }
|
|
+ // Paper end
|
|
PathEntity pathentity = this.a(entity, 1);
|
|
|
|
- return pathentity != null && this.a(pathentity, d0);
|
|
+ // Paper start - Pathfinding optimizations
|
|
+ if (pathentity != null && this.a(pathentity, d0)) {
|
|
+ this.lastFailure = 0;
|
|
+ this.pathfindFailures = 0;
|
|
+ return true;
|
|
+ } else {
|
|
+ this.pathfindFailures++;
|
|
+ this.lastFailure = MinecraftServer.currentTick;
|
|
+ return false;
|
|
+ }
|
|
+ // Paper end
|
|
}
|
|
|
|
public boolean setDestination(@Nullable PathEntity pathentity, double speed) { return a(pathentity, speed); } // Paper - OBFHELPER
|
|
--
|
|
2.26.2
|
|
|