diff --git a/patches/api/0005-Pufferfish-SMID-Utilities.patch b/patches/api/0005-Pufferfish-SMID-Utilities.patch new file mode 100644 index 0000000..670f026 --- /dev/null +++ b/patches/api/0005-Pufferfish-SMID-Utilities.patch @@ -0,0 +1,111 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MrHua269 +Date: Tue, 6 Aug 2024 14:32:22 +0800 +Subject: [PATCH] Pufferfish SMID Utilities + + +diff --git a/build.gradle.kts b/build.gradle.kts +index 540fe7e2c110e79c3742f229b3ed8c54b101d260..3f04b36591899040a8b602db6475de492755ffb5 100644 +--- a/build.gradle.kts ++++ b/build.gradle.kts +@@ -130,6 +130,13 @@ val generateApiVersioningFile by tasks.registering { + } + } + ++// Pufferfish Start ++tasks.withType { ++ val compilerArgs = options.compilerArgs ++ compilerArgs.add("--add-modules=jdk.incubator.vector") ++} ++// Pufferfish End ++ + tasks.jar { + from(generateApiVersioningFile.map { it.outputs.files.singleFile }) { + into("META-INF/maven/${project.group}/${project.name}") +diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java +new file mode 100644 +index 0000000000000000000000000000000000000000..3441cdad70da1bd523c5933b1a914688718c2657 +--- /dev/null ++++ b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java +@@ -0,0 +1,40 @@ ++package gg.pufferfish.pufferfish.simd; ++ ++import java.util.logging.Level; ++import java.util.logging.Logger; ++import jdk.incubator.vector.FloatVector; ++import jdk.incubator.vector.IntVector; ++import jdk.incubator.vector.VectorSpecies; ++ ++/** ++ * Basically, java is annoying and we have to push this out to its own class. ++ */ ++@Deprecated ++public class SIMDChecker { ++ ++ @Deprecated ++ public static boolean canEnable(Logger logger) { ++ try { ++ if (SIMDDetection.getJavaVersion() < 17 || SIMDDetection.getJavaVersion() > 21) { ++ return false; ++ } else { ++ SIMDDetection.testRun = true; ++ ++ VectorSpecies ISPEC = IntVector.SPECIES_PREFERRED; ++ VectorSpecies FSPEC = FloatVector.SPECIES_PREFERRED; ++ ++ logger.log(Level.INFO, "Max SIMD vector size on this system is " + ISPEC.vectorBitSize() + " bits (int)"); ++ logger.log(Level.INFO, "Max SIMD vector size on this system is " + FSPEC.vectorBitSize() + " bits (float)"); ++ ++ if (ISPEC.elementSize() < 2 || FSPEC.elementSize() < 2) { ++ logger.log(Level.WARNING, "SIMD is not properly supported on this system!"); ++ return false; ++ } ++ ++ return true; ++ } ++ } catch (NoClassDefFoundError | Exception ignored) {} // Basically, we don't do anything. This lets us detect if it's not functional and disable it. ++ return false; ++ } ++ ++} +diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java +new file mode 100644 +index 0000000000000000000000000000000000000000..a84889d3e9cfc4d7ab5f867820a6484c6070711b +--- /dev/null ++++ b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java +@@ -0,0 +1,35 @@ ++package gg.pufferfish.pufferfish.simd; ++ ++import java.util.logging.Logger; ++ ++@Deprecated ++public class SIMDDetection { ++ ++ public static boolean isEnabled = false; ++ public static boolean versionLimited = false; ++ public static boolean testRun = false; ++ ++ @Deprecated ++ public static boolean canEnable(Logger logger) { ++ try { ++ return SIMDChecker.canEnable(logger); ++ } catch (NoClassDefFoundError | Exception ignored) { ++ return false; ++ } ++ } ++ ++ @Deprecated ++ public static int getJavaVersion() { ++ // https://stackoverflow.com/a/2591122 ++ String version = System.getProperty("java.version"); ++ if(version.startsWith("1.")) { ++ version = version.substring(2, 3); ++ } else { ++ int dot = version.indexOf("."); ++ if(dot != -1) { version = version.substring(0, dot); } ++ } ++ version = version.split("-")[0]; // Azul is stupid ++ return Integer.parseInt(version); ++ } ++ ++} diff --git a/patches/server/0037-Pufferfish-SMID-Utilities.patch b/patches/server/0037-Pufferfish-SMID-Utilities.patch new file mode 100644 index 0000000..4b2aca1 --- /dev/null +++ b/patches/server/0037-Pufferfish-SMID-Utilities.patch @@ -0,0 +1,83 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MrHua269 +Date: Tue, 6 Aug 2024 14:31:20 +0800 +Subject: [PATCH] Pufferfish SMID Utilities + + +diff --git a/build.gradle.kts b/build.gradle.kts +index c2d3d699edfd60d773af96116c5663c812c691e9..1049681dfa7e48b4b6c29f4b1a09c689ac918500 100644 +--- a/build.gradle.kts ++++ b/build.gradle.kts +@@ -76,6 +76,14 @@ paperweight { + craftBukkitPackageVersion.set("v1_21_R1") // also needs to be updated in MappingEnvironment + } + ++ ++// Pufferfish Start ++tasks.withType { ++ val compilerArgs = options.compilerArgs ++ compilerArgs.add("--add-modules=jdk.incubator.vector") ++} ++// Pufferfish End ++ + tasks.jar { + archiveClassifier.set("dev") + +diff --git a/src/main/java/me/earthme/luminol/config/modules/optimizations/SMIDConfig.java b/src/main/java/me/earthme/luminol/config/modules/optimizations/SMIDConfig.java +new file mode 100644 +index 0000000000000000000000000000000000000000..b2b4a91925145b331a604384afee23ab276d76be +--- /dev/null ++++ b/src/main/java/me/earthme/luminol/config/modules/optimizations/SMIDConfig.java +@@ -0,0 +1,52 @@ ++package me.earthme.luminol.config.modules.optimizations; ++ ++import com.electronwill.nightconfig.core.file.CommentedFileConfig; ++import com.mojang.logging.LogUtils; ++import me.earthme.luminol.config.ConfigInfo; ++import me.earthme.luminol.config.DoNotLoad; ++import me.earthme.luminol.config.EnumConfigCategory; ++import me.earthme.luminol.config.IConfigModule; ++import org.slf4j.Logger; ++ ++public class SMIDConfig implements IConfigModule { ++ @DoNotLoad ++ private static final Logger LOGGER = LogUtils.getLogger(); ++ @ConfigInfo(baseName = "enabled") ++ public static boolean enabled = true; ++ ++ @Override ++ public EnumConfigCategory getCategory() { ++ return EnumConfigCategory.OPTIMIZATIONS; ++ } ++ ++ @Override ++ public String getBaseName() { ++ return "use_smid"; ++ } ++ ++ @Override ++ public void onLoaded(CommentedFileConfig configInstance) { ++ if (!enabled){ ++ return; ++ } ++ ++ // Attempt to detect vectorization ++ try { ++ SIMDDetection.isEnabled = SIMDDetection.canEnable(LOGGER); ++ SIMDDetection.versionLimited = SIMDDetection.getJavaVersion() < 17 || SIMDDetection.getJavaVersion() > 21; ++ } catch (NoClassDefFoundError | Exception ignored) { ++ ignored.printStackTrace(); ++ } ++ ++ if (SIMDDetection.isEnabled) { ++ LOGGER.info("SIMD operations detected as functional. Will replace some operations with faster versions."); ++ } else if (SIMDDetection.versionLimited) { ++ LOGGER.warn("Will not enable SIMD! These optimizations are only safely supported on Java 17-21."); ++ } else { ++ LOGGER.warn("SIMD operations are available for your server, but are not configured!"); ++ LOGGER.warn("To enable additional optimizations, add \"--add-modules=jdk.incubator.vector\" to your startup flags, BEFORE the \"-jar\"."); ++ LOGGER.warn("If you have already added this flag, then SIMD operations are not supported on your JVM or CPU."); ++ LOGGER.warn("Debug: Java: " + System.getProperty("java.version") + ", test run: " + SIMDDetection.testRun); ++ } ++ } ++} diff --git a/patches/server/0037-Gale-Variable-entity-wake-up-duration.patch b/patches/server/0038-Gale-Variable-entity-wake-up-duration.patch similarity index 100% rename from patches/server/0037-Gale-Variable-entity-wake-up-duration.patch rename to patches/server/0038-Gale-Variable-entity-wake-up-duration.patch diff --git a/patches/server/0038-Gale-Optimize-sun-burn-tick.patch b/patches/server/0039-Gale-Optimize-sun-burn-tick.patch similarity index 100% rename from patches/server/0038-Gale-Optimize-sun-burn-tick.patch rename to patches/server/0039-Gale-Optimize-sun-burn-tick.patch diff --git a/patches/server/0039-Gale-Use-platform-math-functions.patch b/patches/server/0040-Gale-Use-platform-math-functions.patch similarity index 100% rename from patches/server/0039-Gale-Use-platform-math-functions.patch rename to patches/server/0040-Gale-Use-platform-math-functions.patch diff --git a/patches/server/0040-Gale-Skip-entity-move-if-movement-is-zero.patch b/patches/server/0041-Gale-Skip-entity-move-if-movement-is-zero.patch similarity index 100% rename from patches/server/0040-Gale-Skip-entity-move-if-movement-is-zero.patch rename to patches/server/0041-Gale-Skip-entity-move-if-movement-is-zero.patch diff --git a/patches/server/0041-Gale-Optimize-noise-generation.patch b/patches/server/0042-Gale-Optimize-noise-generation.patch similarity index 100% rename from patches/server/0041-Gale-Optimize-noise-generation.patch rename to patches/server/0042-Gale-Optimize-noise-generation.patch diff --git a/patches/server/0042-Gale-Faster-chunk-serialization.patch b/patches/server/0043-Gale-Faster-chunk-serialization.patch similarity index 100% rename from patches/server/0042-Gale-Faster-chunk-serialization.patch rename to patches/server/0043-Gale-Faster-chunk-serialization.patch diff --git a/patches/server/0043-Gale-Reduce-lambda-and-Optional-allocation-in-Entity.patch b/patches/server/0044-Gale-Reduce-lambda-and-Optional-allocation-in-Entity.patch similarity index 100% rename from patches/server/0043-Gale-Reduce-lambda-and-Optional-allocation-in-Entity.patch rename to patches/server/0044-Gale-Reduce-lambda-and-Optional-allocation-in-Entity.patch diff --git a/patches/server/0044-Gale-Replace-throttle-tracker-map-with-optimized-col.patch b/patches/server/0045-Gale-Replace-throttle-tracker-map-with-optimized-col.patch similarity index 100% rename from patches/server/0044-Gale-Replace-throttle-tracker-map-with-optimized-col.patch rename to patches/server/0045-Gale-Replace-throttle-tracker-map-with-optimized-col.patch diff --git a/patches/server/0045-Sparkly-Paper-Optimize-canSee-checks.patch b/patches/server/0046-Sparkly-Paper-Optimize-canSee-checks.patch similarity index 100% rename from patches/server/0045-Sparkly-Paper-Optimize-canSee-checks.patch rename to patches/server/0046-Sparkly-Paper-Optimize-canSee-checks.patch diff --git a/patches/server/0046-SparklyPaper-Skip-MapItem-update-if-the-map-does-not.patch b/patches/server/0047-SparklyPaper-Skip-MapItem-update-if-the-map-does-not.patch similarity index 100% rename from patches/server/0046-SparklyPaper-Skip-MapItem-update-if-the-map-does-not.patch rename to patches/server/0047-SparklyPaper-Skip-MapItem-update-if-the-map-does-not.patch diff --git a/patches/server/0047-SparklyPaper-Skip-distanceToSqr-call-in-ServerEntity.patch b/patches/server/0048-SparklyPaper-Skip-distanceToSqr-call-in-ServerEntity.patch similarity index 100% rename from patches/server/0047-SparklyPaper-Skip-distanceToSqr-call-in-ServerEntity.patch rename to patches/server/0048-SparklyPaper-Skip-distanceToSqr-call-in-ServerEntity.patch diff --git a/patches/server/0048-KioCG-Chunk-API-and-display-of-chunkhot-in-tpsbar.patch b/patches/server/0049-KioCG-Chunk-API-and-display-of-chunkhot-in-tpsbar.patch similarity index 100% rename from patches/server/0048-KioCG-Chunk-API-and-display-of-chunkhot-in-tpsbar.patch rename to patches/server/0049-KioCG-Chunk-API-and-display-of-chunkhot-in-tpsbar.patch diff --git a/patches/server/0049-Purpur-use-alternative-keep-alive.patch b/patches/server/0050-Purpur-use-alternative-keep-alive.patch similarity index 100% rename from patches/server/0049-Purpur-use-alternative-keep-alive.patch rename to patches/server/0050-Purpur-use-alternative-keep-alive.patch diff --git a/patches/server/0050-Leaf-Skip-event-if-no-listeners.patch b/patches/server/0051-Leaf-Skip-event-if-no-listeners.patch similarity index 100% rename from patches/server/0050-Leaf-Skip-event-if-no-listeners.patch rename to patches/server/0051-Leaf-Skip-event-if-no-listeners.patch diff --git a/patches/server/0051-Threaded-region-start-tick-and-finished-tick-event.patch b/patches/server/0052-Threaded-region-start-tick-and-finished-tick-event.patch similarity index 100% rename from patches/server/0051-Threaded-region-start-tick-and-finished-tick-event.patch rename to patches/server/0052-Threaded-region-start-tick-and-finished-tick-event.patch diff --git a/patches/server/0052-Fix-MC-2025.patch b/patches/server/0053-Fix-MC-2025.patch similarity index 100% rename from patches/server/0052-Fix-MC-2025.patch rename to patches/server/0053-Fix-MC-2025.patch diff --git a/patches/server/0053-FoliaPR-Add-TPS-From-Region.patch b/patches/server/0054-FoliaPR-Add-TPS-From-Region.patch similarity index 100% rename from patches/server/0053-FoliaPR-Add-TPS-From-Region.patch rename to patches/server/0054-FoliaPR-Add-TPS-From-Region.patch