From 1ef5dc7644e7b0f42937c7ad2dfc58faddbfa98d Mon Sep 17 00:00:00 2001 From: Aikar Date: Sun, 26 Aug 2018 20:49:50 -0400 Subject: [PATCH] Optimize MappedRegistry Use larger initial sizes to increase bucket capacity on the BiMap BiMap.get was seen to be using a good bit of CPU time. --- .../minecraft/core/MappedRegistry.java.patch | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 paper-server/patches/sources/net/minecraft/core/MappedRegistry.java.patch diff --git a/paper-server/patches/sources/net/minecraft/core/MappedRegistry.java.patch b/paper-server/patches/sources/net/minecraft/core/MappedRegistry.java.patch new file mode 100644 index 0000000000..8599466b69 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/core/MappedRegistry.java.patch @@ -0,0 +1,19 @@ +--- a/net/minecraft/core/MappedRegistry.java ++++ b/net/minecraft/core/MappedRegistry.java +@@ -33,11 +33,11 @@ + public class MappedRegistry implements WritableRegistry { + private final ResourceKey> key; + private final ObjectList> byId = new ObjectArrayList<>(256); +- private final Reference2IntMap toId = Util.make(new Reference2IntOpenHashMap<>(), map -> map.defaultReturnValue(-1)); +- private final Map> byLocation = new HashMap<>(); +- private final Map, Holder.Reference> byKey = new HashMap<>(); +- private final Map> byValue = new IdentityHashMap<>(); +- private final Map, RegistrationInfo> registrationInfos = new IdentityHashMap<>(); ++ private final Reference2IntMap toId = Util.make(new Reference2IntOpenHashMap<>(2048), map -> map.defaultReturnValue(-1)); // Paper - Perf: Use bigger expected size to reduce collisions ++ private final Map> byLocation = new HashMap<>(2048); // Paper - Perf: Use bigger expected size to reduce collisions ++ private final Map, Holder.Reference> byKey = new HashMap<>(2048); // Paper - Perf: Use bigger expected size to reduce collisions ++ private final Map> byValue = new IdentityHashMap<>(2048); // Paper - Perf: Use bigger expected size to reduce collisions ++ private final Map, RegistrationInfo> registrationInfos = new IdentityHashMap<>(2048); // Paper - Perf: Use bigger expected size to reduce collisions + private Lifecycle registryLifecycle; + private final Map, HolderSet.Named> frozenTags = new IdentityHashMap<>(); + MappedRegistry.TagSet allTags = MappedRegistry.TagSet.unbound();