mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-24 16:18:02 +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.
35 lines
1.5 KiB
Diff
35 lines
1.5 KiB
Diff
From 5deb0eb94ead4e4a486ec4bcdd8eab5554935401 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Wed, 27 Mar 2019 22:48:45 -0400
|
|
Subject: [PATCH] Server Tick Events
|
|
|
|
Fires event at start and end of a server tick
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
index 3d9cc2ce67b..249eaf56bc0 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -1089,6 +1089,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
|
});
|
|
isOversleep = false;MinecraftTimings.serverOversleep.stopTiming();
|
|
// Paper end
|
|
+ new com.destroystokyo.paper.event.server.ServerTickStartEvent(this.ticks+1).callEvent(); // Paper
|
|
|
|
++this.ticks;
|
|
this.b(booleansupplier);
|
|
@@ -1132,6 +1133,12 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
|
}
|
|
// Paper end
|
|
|
|
+ // Paper start
|
|
+ long endTime = System.nanoTime();
|
|
+ long remaining = (TICK_TIME - (endTime - lastTick)) - catchupTime;
|
|
+ new com.destroystokyo.paper.event.server.ServerTickEndEvent(this.ticks, ((double)(endTime - lastTick) / 1000000D), remaining).callEvent();
|
|
+ // Paper end
|
|
+
|
|
this.methodProfiler.enter("tallying");
|
|
long l = this.f[this.ticks % 100] = SystemUtils.getMonotonicNanos() - i;
|
|
|
|
--
|
|
2.26.2
|
|
|