Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-16 03:20:07 +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.
66 Zeilen
2.7 KiB
Diff
66 Zeilen
2.7 KiB
Diff
From 6268c9dcf697b86724085367d7ad14ddea65d49b Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
Date: Tue, 14 Jan 2020 14:59:08 -0800
|
|
Subject: [PATCH] Optimise Chunk#getFluid
|
|
|
|
Removing the try catch and generally reducing ops should make it
|
|
faster on its own, however removing the try catch makes it
|
|
easier to inline due to code size
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
|
index bb95fe20e8a..33456b0bb42 100644
|
|
--- a/src/main/java/net/minecraft/server/Chunk.java
|
|
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
|
@@ -379,17 +379,20 @@ public class Chunk implements IChunkAccess {
|
|
}
|
|
|
|
public Fluid a(int i, int j, int k) {
|
|
- try {
|
|
- if (j >= 0 && j >> 4 < this.sections.length) {
|
|
- ChunkSection chunksection = this.sections[j >> 4];
|
|
-
|
|
- if (!ChunkSection.a(chunksection)) {
|
|
- return chunksection.b(i & 15, j & 15, k & 15);
|
|
+ //try { // Paper - remove try catch
|
|
+ // Paper start - reduce the number of ops in this call
|
|
+ int index = j >> 4;
|
|
+ if (index >= 0 && index < this.sections.length) {
|
|
+ ChunkSection chunksection = this.sections[index];
|
|
+
|
|
+ if (chunksection != null) {
|
|
+ return chunksection.blockIds.a((j & 15) << 8 | (k & 15) << 4 | i & 15).getFluid();
|
|
}
|
|
+ // Paper end
|
|
}
|
|
|
|
return FluidTypes.EMPTY.h();
|
|
- } catch (Throwable throwable) {
|
|
+ /*} catch (Throwable throwable) { // Paper - remove try catch
|
|
CrashReport crashreport = CrashReport.a(throwable, "Getting fluid state");
|
|
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Block being got");
|
|
|
|
@@ -398,6 +401,7 @@ public class Chunk implements IChunkAccess {
|
|
});
|
|
throw new ReportedException(crashreport);
|
|
}
|
|
+ */ // Paper - remove try catch
|
|
}
|
|
|
|
// CraftBukkit start
|
|
diff --git a/src/main/java/net/minecraft/server/ChunkSection.java b/src/main/java/net/minecraft/server/ChunkSection.java
|
|
index 64b625e988f..b7b06e082e5 100644
|
|
--- a/src/main/java/net/minecraft/server/ChunkSection.java
|
|
+++ b/src/main/java/net/minecraft/server/ChunkSection.java
|
|
@@ -37,7 +37,7 @@ public class ChunkSection {
|
|
}
|
|
|
|
public Fluid b(int i, int j, int k) {
|
|
- return ((IBlockData) this.blockIds.a(i, j, k)).getFluid();
|
|
+ return ((IBlockData) this.blockIds.a(i, j, k)).getFluid(); // Paper - diff on change - we expect this to be effectively just getType(x, y, z).getFluid(). If this changes we need to check other patches that use IBlockData#getFluid.
|
|
}
|
|
|
|
public void a() {
|
|
--
|
|
2.26.2
|
|
|