diff --git a/patches/server/0003-Optimize-entity-coordinate-key.patch b/patches/server/0003-Optimize-entity-coordinate-key.patch new file mode 100644 index 0000000..db89a48 --- /dev/null +++ b/patches/server/0003-Optimize-entity-coordinate-key.patch @@ -0,0 +1,38 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Kevin Raneri +Date: Tue, 9 Nov 2021 14:33:16 -0500 +Subject: [PATCH] Optimize entity coordinate key + +When executing getCoordinateKey for entities (a hotpath), the JVM is +required to repeatedly cast doubles to longs. The performance impact of +this depends on the CPU architecture, but generally switching between +FPU and ALU incurs a significant performance hit. The casted/rounded +data is already available in the blockPosition struct, so we use that +instead of re-doing the casting. + +diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java +index d02546b18cb689724887b4e85e8d32a18828a4ad..91eaff58bb422ba188e6cfaa9c20b45bec211edd 100644 +--- a/src/main/java/io/papermc/paper/util/MCUtil.java ++++ b/src/main/java/io/papermc/paper/util/MCUtil.java +@@ -213,7 +213,7 @@ public final class MCUtil { + } + + public static long getCoordinateKey(final Entity entity) { +- return ((long)(MCUtil.fastFloor(entity.getZ()) >> 4) << 32) | ((MCUtil.fastFloor(entity.getX()) >> 4) & 0xFFFFFFFFL); ++ return ((long)(entity.blockPosition.getZ() >> 4) << 32) | ((entity.blockPosition.getX() >> 4) & 0xFFFFFFFFL); // Pufferfish - eliminate double->long cast in hotpath + } + + public static long getCoordinateKey(final ChunkPos pair) { +diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java +index d435d04ab50b2f64e6438c6c26639b6048322013..9906cde792a07a433e45613518e741801026077d 100644 +--- a/src/main/java/net/minecraft/world/entity/Entity.java ++++ b/src/main/java/net/minecraft/world/entity/Entity.java +@@ -306,7 +306,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { + public double yo; + public double zo; + private Vec3 position; +- private BlockPos blockPosition; ++ public BlockPos blockPosition; // Pufferfish - private->public + private ChunkPos chunkPosition; + private Vec3 deltaMovement; + private float yRot; diff --git a/patches/server/0003-Configurable-Farm-Land-moisture-tick-rate-when-the-b.patch b/patches/server/0004-Configurable-Farm-Land-moisture-tick-rate-when-the-b.patch similarity index 100% rename from patches/server/0003-Configurable-Farm-Land-moisture-tick-rate-when-the-b.patch rename to patches/server/0004-Configurable-Farm-Land-moisture-tick-rate-when-the-b.patch diff --git a/patches/server/0004-Track-how-much-MSPT-each-world-used.patch b/patches/server/0005-Track-how-much-MSPT-each-world-used.patch similarity index 100% rename from patches/server/0004-Track-how-much-MSPT-each-world-used.patch rename to patches/server/0005-Track-how-much-MSPT-each-world-used.patch diff --git a/patches/server/0005-Parallel-world-ticking.patch b/patches/server/0006-Parallel-world-ticking.patch similarity index 100% rename from patches/server/0005-Parallel-world-ticking.patch rename to patches/server/0006-Parallel-world-ticking.patch