From feacfb991d949fa2995c0d5ea468a3bd76c1a6c9 Mon Sep 17 00:00:00 2001 From: md_5 Date: Wed, 29 Jan 2014 09:04:51 +1100 Subject: [PATCH] [Experimental] - Enable compressed bulk chunk cache. Sort chunks a final time before sending. This gives the advantage that chunks will load as close to the player as they possibly can, and then move out, as well as increase the cache hit rate when using smaller bulk chunk limits such as the default of 5. --- ...ed-Bulk-Chunk-Compression-and-Cachin.patch | 47 ++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/CraftBukkit-Patches/0105-Implement-Threaded-Bulk-Chunk-Compression-and-Cachin.patch b/CraftBukkit-Patches/0105-Implement-Threaded-Bulk-Chunk-Compression-and-Cachin.patch index 57609480d..86ca363a7 100644 --- a/CraftBukkit-Patches/0105-Implement-Threaded-Bulk-Chunk-Compression-and-Cachin.patch +++ b/CraftBukkit-Patches/0105-Implement-Threaded-Bulk-Chunk-Compression-and-Cachin.patch @@ -1,9 +1,21 @@ -From c1d148a1f2b801d24c81d9ffdbfb8669de69cc55 Mon Sep 17 00:00:00 2001 +From ec5eb62165143ba7444a7f39afe0e24d4032370a Mon Sep 17 00:00:00 2001 From: md_5 Date: Tue, 28 Jan 2014 20:32:07 +1100 Subject: [PATCH] Implement Threaded Bulk Chunk Compression and Caching +diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java +index 9b853a9..a4c8843 100644 +--- a/src/main/java/net/minecraft/server/EntityPlayer.java ++++ b/src/main/java/net/minecraft/server/EntityPlayer.java +@@ -228,6 +228,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { + } + + if (!arraylist.isEmpty()) { ++ java.util.Collections.sort( arraylist, new PlayerChunkMap.ChunkComparator( this ) ); // Spigot - sort a final time before sending + this.playerConnection.sendPacket(new PacketPlayOutMapChunkBulk(arraylist)); + Iterator iterator2 = arraylist1.iterator(); + diff --git a/src/main/java/net/minecraft/server/PacketPlayOutMapChunkBulk.java b/src/main/java/net/minecraft/server/PacketPlayOutMapChunkBulk.java index 30bf8a7..e05c870 100644 --- a/src/main/java/net/minecraft/server/PacketPlayOutMapChunkBulk.java @@ -35,6 +47,39 @@ index 30bf8a7..e05c870 100644 packetdataserializer.writeShort(this.a.length); packetdataserializer.writeInt(this.size); packetdataserializer.writeBoolean(this.h); +diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java +index ae4ca63..962e902 100644 +--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java ++++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java +@@ -279,8 +279,27 @@ public class PlayerChunkMap { + return playermanager.d; + } + ++ // Spigot Start ++ public static class ChunkComparator implements java.util.Comparator ++ { ++ ++ private final ChunkCoordComparator base; ++ ++ public ChunkComparator(EntityPlayer player) ++ { ++ this.base = new ChunkCoordComparator( player ); ++ } ++ ++ @Override ++ public int compare(Chunk o1, Chunk o2) ++ { ++ return base.compare( o1.l(), o2.l() ); ++ } ++ ++ } + // CraftBukkit start - Sorter to load nearby chunks first +- private static class ChunkCoordComparator implements java.util.Comparator { ++ public static class ChunkCoordComparator implements java.util.Comparator { ++ // Spigot End + private int x; + private int z; + diff --git a/src/main/java/net/minecraft/server/ServerConnectionChannel.java b/src/main/java/net/minecraft/server/ServerConnectionChannel.java index fb95be4..2875c94 100644 --- a/src/main/java/net/minecraft/server/ServerConnectionChannel.java