From a4d29fef6a2c2fd6e8b02d16f24d0d8cb568d252 Mon Sep 17 00:00:00 2001 From: Aikar Date: Thu, 31 Mar 2016 21:45:30 -0400 Subject: [PATCH] Remove Long2ObjectHashMap for Chunks Speaking with Amaranth, his point of his implementation was that most of the lookups are on loaded chunks, so that code is optimized for that case. While Long2Object should be faster as a general purpose map, for MC uses, Amaranth's version should be faster. Will try to benchmark the 2 at some future. --- ...astUtil-Int-HashMap-for-DataWatcher.patch} | 25 +------------------ 1 file changed, 1 insertion(+), 24 deletions(-) rename Spigot-Server-Patches/{Use-FastUtil-Long-Int-HashMap-s.patch => Use-FastUtil-Int-HashMap-for-DataWatcher.patch} (52%) diff --git a/Spigot-Server-Patches/Use-FastUtil-Long-Int-HashMap-s.patch b/Spigot-Server-Patches/Use-FastUtil-Int-HashMap-for-DataWatcher.patch similarity index 52% rename from Spigot-Server-Patches/Use-FastUtil-Long-Int-HashMap-s.patch rename to Spigot-Server-Patches/Use-FastUtil-Int-HashMap-for-DataWatcher.patch index 976c50ca2..c1fb818a8 100644 --- a/Spigot-Server-Patches/Use-FastUtil-Long-Int-HashMap-s.patch +++ b/Spigot-Server-Patches/Use-FastUtil-Int-HashMap-for-DataWatcher.patch @@ -1,35 +1,13 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Aikar Date: Wed, 30 Mar 2016 02:13:24 -0400 -Subject: [PATCH] Use FastUtil Long/Int HashMap's +Subject: [PATCH] Use FastUtil Int HashMap for DataWatcher For DataWatcher, swap out plain Integer key HashMap for a Int2ObjectOpenHashMap -For ChunkProviderServer, swap out CB's custom LongHashMap with Long2ObjectOpenHashMap These collections are super fast as seen http://java-performance.info/hashmap-overview-jdk-fastutil-goldman-sachs-hppc-koloboke-trove-january-2015/ -diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/ChunkProviderServer.java -+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java -@@ -0,0 +0,0 @@ import java.util.Iterator; - import java.util.List; - - import com.destroystokyo.paper.exception.ServerInternalException; -+import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; // Paper - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; - -@@ -0,0 +0,0 @@ public class ChunkProviderServer implements IChunkProvider { - private final IChunkLoader chunkLoader; - // Paper start - protected Chunk lastChunkByPos = null; -- public LongObjectHashMap chunks = new LongObjectHashMap() { -+ public Long2ObjectOpenHashMap chunks = new Long2ObjectOpenHashMap() { - @Override - public Chunk get(long key) { - if (lastChunkByPos != null && key == lastChunkByPos.chunkKey) { diff --git a/src/main/java/net/minecraft/server/DataWatcher.java b/src/main/java/net/minecraft/server/DataWatcher.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/DataWatcher.java @@ -38,7 +16,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import java.util.Map; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; -+ +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; // Paper import org.apache.commons.lang3.ObjectUtils;