Optimise NetworkManager

This commit is contained in:
Alfie Cleveland 2016-11-25 20:35:15 +00:00 committed by Zach Brown
parent 4056a8b468
commit 324acd64b4
No known key found for this signature in database
GPG key ID: CC9DA35FC5450B76
5 changed files with 113 additions and 17 deletions

View file

@ -1,14 +1,14 @@
From 90daaa2067899aa0bea025e45ee3e98ad862275a Mon Sep 17 00:00:00 2001
From 38e2ee2f9337fc85740266713d841dada00b1e59 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 29 Feb 2016 17:43:33 -0600
Subject: [PATCH] Add async chunk load API
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index 339afe4..ce92fef 100644
index 37e6419..4deb492 100644
--- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java
@@ -135,6 +135,78 @@ public interface World extends PluginMessageRecipient, Metadatable {
@@ -136,6 +136,78 @@ public interface World extends PluginMessageRecipient, Metadatable {
public Chunk getChunkAt(Block block);
/**
@ -88,5 +88,5 @@ index 339afe4..ce92fef 100644
*
* @param chunk The chunk to check
--
2.9.2.windows.1
2.10.2.windows.1

View file

@ -1,14 +1,14 @@
From 72530f8a0121d4f72bd4b24f9164512ed285288f Mon Sep 17 00:00:00 2001
From d98bd2358838148eef90502ac28710a65df0d423 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Tue, 1 Mar 2016 23:19:01 -0600
Subject: [PATCH] Add async chunk load API
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index bc214af..c507858 100644
index efafbff..a27a9f0 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -125,6 +125,26 @@ public class CraftWorld implements World {
@@ -126,6 +126,26 @@ public class CraftWorld implements World {
}
}
@ -36,5 +36,5 @@ index bc214af..c507858 100644
return this.world.getChunkProviderServer().getChunkAt(x, z).bukkitChunk;
}
--
2.10.2
2.10.2.windows.1

View file

@ -1,4 +1,4 @@
From 18a457e3d241695e085692e53f51dac84f468bfe Mon Sep 17 00:00:00 2001
From 72104ec5ddcbf6be1314825dff3ed0e1644dd413 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 13 Sep 2014 23:14:43 -0400
Subject: [PATCH] Configurable Keep Spawn Loaded range per world
@ -54,7 +54,7 @@ index 6c72e7e..c82ea39 100644
public void a(Packet<?> packet) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 119001c..67e802a 100644
index 5614147..f107221 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -951,7 +951,7 @@ public final class CraftServer implements Server {
@ -67,10 +67,10 @@ index 119001c..67e802a 100644
for (int j = -short1; j <= short1; j += 16) {
for (int k = -short1; k <= short1; k += 16) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 86ca901..18d0323 100644
index a27a9f0..1d70abf 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -1240,8 +1240,9 @@ public class CraftWorld implements World {
@@ -1247,8 +1247,9 @@ public class CraftWorld implements World {
int chunkCoordX = chunkcoordinates.getX() >> 4;
int chunkCoordZ = chunkcoordinates.getZ() >> 4;
// Cycle through the 25x25 Chunks around it to load/unload the chunks.
@ -83,5 +83,5 @@ index 86ca901..18d0323 100644
loadChunk(chunkCoordX + x, chunkCoordZ + z);
} else {
--
2.10.2
2.10.2.windows.1

View file

@ -1,4 +1,4 @@
From 4728b78cc78eb596816d42f9b41de657ed80c243 Mon Sep 17 00:00:00 2001
From 0ea073bb6aa61144d42ce61b9a166b430da7d527 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 18 Jun 2016 23:22:12 -0400
Subject: [PATCH] Delay Chunk Unloads based on Player Movement
@ -127,10 +127,10 @@ index 8f6f3a0..eae9276 100644
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 18d0323..1296c17 100644
index 1d70abf..b7e063d 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -1533,7 +1533,7 @@ public class CraftWorld implements World {
@@ -1540,7 +1540,7 @@ public class CraftWorld implements World {
ChunkProviderServer cps = world.getChunkProviderServer();
for (net.minecraft.server.Chunk chunk : cps.chunks.values()) {
// If in use, skip it
@ -140,5 +140,5 @@ index 18d0323..1296c17 100644
}
--
2.10.2
2.10.2.windows.1

View file

@ -0,0 +1,96 @@
From d2374b6257ad5d1aa24289572ec3f6ef21006759 Mon Sep 17 00:00:00 2001
From: Alfie Cleveland <alfeh@me.com>
Date: Fri, 25 Nov 2016 20:35:05 +0000
Subject: [PATCH] Optimise NetworkManager
diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
index 184ef32..cca3237 100644
--- a/src/main/java/net/minecraft/server/NetworkManager.java
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
@@ -62,8 +62,8 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
}
};
private final EnumProtocolDirection h;
- private final Queue<NetworkManager.QueuedPacket> i = Queues.newConcurrentLinkedQueue();
- private final ReentrantReadWriteLock j = new ReentrantReadWriteLock();
+ // private final Queue<NetworkManager.QueuedPacket> i = Queues.newConcurrentLinkedQueue(); // Paper
+ // private final ReentrantReadWriteLock j = new ReentrantReadWriteLock(); // Paper
public Channel channel;
// Spigot Start // PAIL
public SocketAddress l;
@@ -141,7 +141,9 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
if (this.isConnected()) {
this.m();
this.a(packet, (GenericFutureListener[]) null);
- } else {
+ }
+ // Paper start
+ /* else {
this.j.writeLock().lock();
try {
@@ -149,15 +151,18 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
} finally {
this.j.writeLock().unlock();
}
- }
-
+ }*/
+ // Paper end
}
public void sendPacket(Packet<?> packet, GenericFutureListener<? extends Future<? super Void>> genericfuturelistener, GenericFutureListener<? extends Future<? super Void>>... agenericfuturelistener) {
if (this.isConnected()) {
this.m();
this.a(packet, (GenericFutureListener[]) ArrayUtils.add(agenericfuturelistener, 0, genericfuturelistener));
- } else {
+ }
+ // Paper start
+ /*
+ else {
this.j.writeLock().lock();
try {
@@ -166,7 +171,8 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
this.j.writeLock().unlock();
}
}
-
+ */
+ // Paper end
}
private void a(final Packet<?> packet, @Nullable final GenericFutureListener<? extends Future<? super Void>>[] agenericfuturelistener) {
@@ -211,7 +217,8 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
}
private void m() {
- if (this.channel != null && this.channel.isOpen()) {
+ // Paper start
+ /* if (this.channel != null && this.channel.isOpen()) {
this.j.readLock().lock();
try {
@@ -224,7 +231,8 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
this.j.readLock().unlock();
}
- }
+ }*/
+ // Paper end
}
public void a() {
@@ -317,7 +325,7 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
} else if (this.i() != null) {
this.i().a(new ChatComponentText("Disconnected"));
}
- this.i.clear(); // Free up packet queue.
+ // this.i.clear(); // Free up packet queue. // Paper - remove unneeded packet queue
}
}
--
2.9.3 (Apple Git-75)