Remove MOST Synchronization from Chunk Map
This will provide quite a major performance boost by avoiding synchronizing on EVERY chunk lookup. Synchronize, even without contention, incurs processor cache flushes. Considering this is the 2nd hottest method in the code base, lets avoid doing that... Additionally, chunk conversion operations were occuring while under synchronization which lead to deadlocks. Now the conversion will occur outside of the lock, and fix that issue, resolving #1586 Note, that the chunk map is still thread safe for get operations! The chunk map was never intended to be modified async with our changes, as we post to main to modify the map, however we do still synchronize for write operations (put, remove) We also synchronize for async get operations, ensuring that async gets are safe. We do not need to synchronize main thread gets as the processor cache will be insync since the map is only updated on the main thread. However, if someone does try to delete or put concurrently, we will force their operation back to the main thread.
This commit is contained in:
@@ -14,7 +14,7 @@ forwarding, and is integrated into the Minecraft login process by using the 1.13
|
||||
login plugin message packet.
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
index 352166725..70f650bb2 100644
|
||||
index 7ac07ac07ac0..7ac07ac07ac0 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
@@ -0,0 +0,0 @@ import java.io.IOException;
|
||||
@@ -55,7 +55,7 @@ index 352166725..70f650bb2 100644
|
||||
}
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/proxy/VelocityProxy.java b/src/main/java/com/destroystokyo/paper/proxy/VelocityProxy.java
|
||||
new file mode 100644
|
||||
index 000000000..fdd8708f9
|
||||
index 7ac07ac07ac0..7ac07ac07ac0
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/proxy/VelocityProxy.java
|
||||
@@ -0,0 +0,0 @@
|
||||
@@ -127,7 +127,7 @@ index 000000000..fdd8708f9
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/LoginListener.java b/src/main/java/net/minecraft/server/LoginListener.java
|
||||
index 5778a5201..b6a3992a3 100644
|
||||
index 7ac07ac07ac0..7ac07ac07ac0 100644
|
||||
--- a/src/main/java/net/minecraft/server/LoginListener.java
|
||||
+++ b/src/main/java/net/minecraft/server/LoginListener.java
|
||||
@@ -0,0 +0,0 @@ public class LoginListener implements PacketLoginInListener, ITickable {
|
||||
@@ -203,7 +203,7 @@ index 5778a5201..b6a3992a3 100644
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
|
||||
index b2afec5e4..97a9dffe6 100644
|
||||
index 7ac07ac07ac0..7ac07ac07ac0 100644
|
||||
--- a/src/main/java/net/minecraft/server/NetworkManager.java
|
||||
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
|
||||
@@ -0,0 +0,0 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
|
||||
@@ -216,7 +216,7 @@ index b2afec5e4..97a9dffe6 100644
|
||||
public com.mojang.authlib.properties.Property[] spoofedProfile;
|
||||
public boolean preparing = true;
|
||||
diff --git a/src/main/java/net/minecraft/server/PacketDataSerializer.java b/src/main/java/net/minecraft/server/PacketDataSerializer.java
|
||||
index cab837483..fb6e373f0 100644
|
||||
index 7ac07ac07ac0..7ac07ac07ac0 100644
|
||||
--- a/src/main/java/net/minecraft/server/PacketDataSerializer.java
|
||||
+++ b/src/main/java/net/minecraft/server/PacketDataSerializer.java
|
||||
@@ -0,0 +0,0 @@ public class PacketDataSerializer extends ByteBuf {
|
||||
@@ -244,7 +244,7 @@ index cab837483..fb6e373f0 100644
|
||||
int j = this.g();
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PacketLoginInCustomPayload.java b/src/main/java/net/minecraft/server/PacketLoginInCustomPayload.java
|
||||
index e3c0094f7..edfd4a506 100644
|
||||
index 7ac07ac07ac0..7ac07ac07ac0 100644
|
||||
--- a/src/main/java/net/minecraft/server/PacketLoginInCustomPayload.java
|
||||
+++ b/src/main/java/net/minecraft/server/PacketLoginInCustomPayload.java
|
||||
@@ -0,0 +0,0 @@ package net.minecraft.server;
|
||||
@@ -259,7 +259,7 @@ index e3c0094f7..edfd4a506 100644
|
||||
public PacketLoginInCustomPayload() {
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/PacketLoginOutCustomPayload.java b/src/main/java/net/minecraft/server/PacketLoginOutCustomPayload.java
|
||||
index 9c5559ece..9de0421bb 100644
|
||||
index 7ac07ac07ac0..7ac07ac07ac0 100644
|
||||
--- a/src/main/java/net/minecraft/server/PacketLoginOutCustomPayload.java
|
||||
+++ b/src/main/java/net/minecraft/server/PacketLoginOutCustomPayload.java
|
||||
@@ -0,0 +0,0 @@ public class PacketLoginOutCustomPayload implements Packet<PacketLoginOutListene
|
||||
|
||||
Reference in New Issue
Block a user