diff --git a/patches/server/0008-Gale-semantic-version.patch b/patches/server/0008-Gale-semantic-version.patch index 940a5c7..2f72216 100644 --- a/patches/server/0008-Gale-semantic-version.patch +++ b/patches/server/0008-Gale-semantic-version.patch @@ -29,7 +29,7 @@ index 2868dab7b100d9c325b0e5056f86660d631dec4b..2acad4c3fd58178b0f8b22bdb04eeeeb } diff --git a/src/main/java/org/galemc/gale/version/GaleSemanticVersion.java b/src/main/java/org/galemc/gale/version/GaleSemanticVersion.java new file mode 100644 -index 0000000000000000000000000000000000000000..33df2d291c53c31f7594bca1ca5c92d80c9047fc +index 0000000000000000000000000000000000000000..86f7e352f47ee808f4a8ed00f5773aeb4eab6051 --- /dev/null +++ b/src/main/java/org/galemc/gale/version/GaleSemanticVersion.java @@ -0,0 +1,37 @@ @@ -57,7 +57,7 @@ index 0000000000000000000000000000000000000000..33df2d291c53c31f7594bca1ca5c92d8 + * The patch version is incremented for small changes that do not affect the goal of any feature, + * such as bug fixes, performance improvements or changes in wording. + */ -+ public static final @NotNull String version = "0.5.7"; ++ public static final @NotNull String version = "0.5.8"; + + /** + * The "major.minor" portion of the {@link #version}. diff --git a/patches/server/0145-Optimize-nearest-structure-border-iteration.patch b/patches/server/0140-Optimize-nearest-structure-border-iteration.patch similarity index 100% rename from patches/server/0145-Optimize-nearest-structure-border-iteration.patch rename to patches/server/0140-Optimize-nearest-structure-border-iteration.patch diff --git a/patches/server/0141-Pre-compute-VarInt-and-VarLong-sizes.patch b/patches/server/0141-Pre-compute-VarInt-and-VarLong-sizes.patch new file mode 100644 index 0000000..f808c36 --- /dev/null +++ b/patches/server/0141-Pre-compute-VarInt-and-VarLong-sizes.patch @@ -0,0 +1,67 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Mon, 21 Aug 2023 21:46:10 +0200 +Subject: [PATCH] Pre-compute VarInt and VarLong sizes + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following commit: +"Reapply "Optimize varint writing"" +By: Andrew Steinborn +As part of: Velocity (https://github.com/PaperMC/Velocity) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +* Velocity description * + +Inspired by the approach described at the bottom of https://richardstartin.github.io/posts/dont-use-protobuf-for-telemetry + +Given that we do a lot of varint writing as well, this should provide a small performance boost for larger/complex packets whilst not regressing hard on smaller packets. + +This includes a test to ensure that the behavior is as expected and fixes the initialization loop so that the correct results will be given. Much thanks to @octylFractal for acting as my duck while trying to figure this out. + +diff --git a/src/main/java/net/minecraft/network/FriendlyByteBuf.java b/src/main/java/net/minecraft/network/FriendlyByteBuf.java +index 9938bb90bef84cf784f9a1ceb02a1a45aa8b48a1..ec8203e0f69d976fc35fd2c031b9ecd5565c9591 100644 +--- a/src/main/java/net/minecraft/network/FriendlyByteBuf.java ++++ b/src/main/java/net/minecraft/network/FriendlyByteBuf.java +@@ -102,24 +102,27 @@ public class FriendlyByteBuf extends ByteBuf { + this.source = parent; + } + +- public static int getVarIntSize(int value) { +- for (int j = 1; j < 5; ++j) { +- if ((value & -1 << j * 7) == 0) { +- return j; +- } ++ // Gale start - Velocity - pre-compute VarInt and VarLong sizes ++ private static final int[] VARINT_EXACT_BYTE_LENGTHS = new int[33]; ++ private static final int[] VARLONG_EXACT_BYTE_LENGTHS = new int[65]; ++ static { ++ for (int i = 0; i < 32; ++i) { ++ VARINT_EXACT_BYTE_LENGTHS[i] = (32 - i + 6) / 7; + } ++ VARINT_EXACT_BYTE_LENGTHS[32] = 1; // Special case for the number 0. ++ for (int i = 0; i < 64; ++i) { ++ VARLONG_EXACT_BYTE_LENGTHS[i] = (64 - i + 6) / 7; ++ } ++ VARLONG_EXACT_BYTE_LENGTHS[32] = 1; // Special case for the number 0. ++ } ++ // Gale end - Velocity - pre-compute VarInt and VarLong sizes + +- return 5; ++ public static int getVarIntSize(int value) { ++ return VARINT_EXACT_BYTE_LENGTHS[Integer.numberOfLeadingZeros(value)]; // Gale - Velocity - pre-compute VarInt and VarLong sizes + } + + public static int getVarLongSize(long value) { +- for (int j = 1; j < 10; ++j) { +- if ((value & -1L << j * 7) == 0L) { +- return j; +- } +- } +- +- return 10; ++ return VARLONG_EXACT_BYTE_LENGTHS[Long.numberOfLeadingZeros(value)]; // Gale - Velocity - pre-compute VarInt and VarLong sizes + } + + /** @deprecated */ diff --git a/patches/server/0140-Reduce-RandomSource-instances.patch b/patches/server/0142-Reduce-RandomSource-instances.patch similarity index 100% rename from patches/server/0140-Reduce-RandomSource-instances.patch rename to patches/server/0142-Reduce-RandomSource-instances.patch diff --git a/patches/server/0141-Add-xor-shift-random.patch b/patches/server/0143-Add-xor-shift-random.patch similarity index 100% rename from patches/server/0141-Add-xor-shift-random.patch rename to patches/server/0143-Add-xor-shift-random.patch diff --git a/patches/server/0142-Server-thread-priority-environment-variable.patch b/patches/server/0144-Server-thread-priority-environment-variable.patch similarity index 100% rename from patches/server/0142-Server-thread-priority-environment-variable.patch rename to patches/server/0144-Server-thread-priority-environment-variable.patch diff --git a/patches/server/0143-Instantly-continue-on-world-upgrade-finish.patch b/patches/server/0145-Instantly-continue-on-world-upgrade-finish.patch similarity index 100% rename from patches/server/0143-Instantly-continue-on-world-upgrade-finish.patch rename to patches/server/0145-Instantly-continue-on-world-upgrade-finish.patch diff --git a/patches/server/0144-Virtual-thread-support.patch b/patches/server/0146-Virtual-thread-support.patch similarity index 100% rename from patches/server/0144-Virtual-thread-support.patch rename to patches/server/0146-Virtual-thread-support.patch