Winds-Studio / Leaf

Personal Performance fork, A Minecraft Server Software for Winds Network
Other
201 stars 27 forks source link

[Optimization] Use LXM random generator #50

Closed HaHaWTH closed 2 months ago

HaHaWTH commented 2 months ago

This PR adds L64X128MixRandom(LXM) random generator to the RandomSource, which is much faster.

Some JREs does not support LXM generators and will cause a crash, maybe we can handle this more gracefully?

In my tests, Azul zulu JDK doesn't support this, but GraalVM works fine.

Dreeam-qwq commented 2 months ago

Crash when using GraalVM 21 from its website

[20:07:24 INFO]: [STDERR]: java.lang.ExceptionInInitializerError
[20:07:24 INFO]: [STDERR]:      at net.minecraft.util.RandomSource.create(RandomSource.java:31)
[20:07:24 INFO]: [STDERR]:      at net.minecraft.util.RandomSource.create(RandomSource.java:16)
[20:07:24 INFO]: [STDERR]:      at net.minecraft.world.level.levelgen.WorldOptions.randomSeed(WorldOptions.java:132)
[20:07:24 INFO]: [STDERR]:      at net.minecraft.server.dedicated.DedicatedServerProperties.<init>(DedicatedServerProperties.java:172)
[20:07:24 INFO]: [STDERR]:      at net.minecraft.server.dedicated.DedicatedServerProperties.fromFile(DedicatedServerProperties.java:207)
[20:07:24 INFO]: [STDERR]:      at net.minecraft.server.dedicated.DedicatedServerSettings.<init>(DedicatedServerSettings.java:19)
[20:07:24 INFO]: [STDERR]:      at net.minecraft.server.Main.main(Main.java:135)
[20:07:24 INFO]: [STDERR]:      at org.bukkit.craftbukkit.Main.main(Main.java:356)
[20:07:24 INFO]: [STDERR]:      at io.papermc.paperclip.Paperclip.lambda$main$0(Paperclip.java:42)
[20:07:24 INFO]: [STDERR]:      at java.base/java.lang.Thread.run(Thread.java:1583)
[20:07:24 INFO]: [STDERR]: Caused by: java.lang.IllegalArgumentException: No implementation of the random number generator algorithm "L64X128MixRandom" is available
[20:07:24 INFO]: [STDERR]:      at java.base/java.util.random.RandomGeneratorFactory.findProvider(RandomGeneratorFactory.java:229)
[20:07:24 INFO]: [STDERR]:      at java.base/java.util.random.RandomGeneratorFactory.factoryOf(RandomGeneratorFactory.java:275)
[20:07:24 INFO]: [STDERR]:      at java.base/java.util.random.RandomGeneratorFactory.of(RandomGeneratorFactory.java:360)
[20:07:24 INFO]: [STDERR]:      at org.dreeam.leaf.util.math.random.TheFasterRandom.<clinit>(TheFasterRandom.java:17)
[20:07:24 INFO]: [STDERR]:      ... 10 more
HaHaWTH commented 2 months ago

Crash when using GraalVM 21 from its website

[20:07:24 INFO]: [STDERR]: java.lang.ExceptionInInitializerError
[20:07:24 INFO]: [STDERR]:      at net.minecraft.util.RandomSource.create(RandomSource.java:31)
[20:07:24 INFO]: [STDERR]:      at net.minecraft.util.RandomSource.create(RandomSource.java:16)
[20:07:24 INFO]: [STDERR]:      at net.minecraft.world.level.levelgen.WorldOptions.randomSeed(WorldOptions.java:132)
[20:07:24 INFO]: [STDERR]:      at net.minecraft.server.dedicated.DedicatedServerProperties.<init>(DedicatedServerProperties.java:172)
[20:07:24 INFO]: [STDERR]:      at net.minecraft.server.dedicated.DedicatedServerProperties.fromFile(DedicatedServerProperties.java:207)
[20:07:24 INFO]: [STDERR]:      at net.minecraft.server.dedicated.DedicatedServerSettings.<init>(DedicatedServerSettings.java:19)
[20:07:24 INFO]: [STDERR]:      at net.minecraft.server.Main.main(Main.java:135)
[20:07:24 INFO]: [STDERR]:      at org.bukkit.craftbukkit.Main.main(Main.java:356)
[20:07:24 INFO]: [STDERR]:      at io.papermc.paperclip.Paperclip.lambda$main$0(Paperclip.java:42)
[20:07:24 INFO]: [STDERR]:      at java.base/java.lang.Thread.run(Thread.java:1583)
[20:07:24 INFO]: [STDERR]: Caused by: java.lang.IllegalArgumentException: No implementation of the random number generator algorithm "L64X128MixRandom" is available
[20:07:24 INFO]: [STDERR]:      at java.base/java.util.random.RandomGeneratorFactory.findProvider(RandomGeneratorFactory.java:229)
[20:07:24 INFO]: [STDERR]:      at java.base/java.util.random.RandomGeneratorFactory.factoryOf(RandomGeneratorFactory.java:275)
[20:07:24 INFO]: [STDERR]:      at java.base/java.util.random.RandomGeneratorFactory.of(RandomGeneratorFactory.java:360)
[20:07:24 INFO]: [STDERR]:      at org.dreeam.leaf.util.math.random.TheFasterRandom.<clinit>(TheFasterRandom.java:17)
[20:07:24 INFO]: [STDERR]:      ... 10 more

1 min, wait for me to fix this:(

ConquerEarth commented 2 months ago

java version "21.0.3" 2024-04-16 LTS Java(TM) SE Runtime Environment Oracle GraalVM 21.0.3+7.1 (build 21.0.3+7-LTS-jvmci-23.1-b37) Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 21.0.3+7.1 (build 21.0.3+7-LTS-jvmci-23.1-b37, mixed mode, sharing)

[03:21:36] [ServerMain/INFO]: [SparkProviderSource] Purpur: Using user-provided spark plugin instead of our own. [03:21:40] [ServerMain/INFO]: Using 2 threads for Async Pathfinding [03:21:40] [ServerMain/INFO]: Using 2 threads for Async Entity Tracker

[03:21:40] [ServerMain/INFO]: [STDERR]: at net.minecraft.util.RandomSource.a(RandomSource.java:31) [03:21:40] [ServerMain/INFO]: [STDERR]: at net.minecraft.util.RandomSource.a(RandomSource.java:16) [03:21:40] [ServerMain/INFO]: [STDERR]: at net.minecraft.world.level.levelgen.WorldOptions.f(WorldOptions.java:132) [03:21:40] [ServerMain/INFO]: [STDERR]: at net.minecraft.server.dedicated.DedicatedServerProperties.(DedicatedServerProperties.java:172) [03:21:40] [ServerMain/INFO]: [STDERR]: at net.minecraft.server.dedicated.DedicatedServerProperties.fromFile(DedicatedServerProperties.java:207) [03:21:40] [ServerMain/INFO]: [STDERR]: at net.minecraft.server.dedicated.DedicatedServerSettings.(DedicatedServerSettings.java:19) [03:21:40] [ServerMain/INFO]: [STDERR]: at net.minecraft.server.Main.main(Main.java:135) [03:21:40] [ServerMain/INFO]: [STDERR]: at org.bukkit.craftbukkit.Main.main(Main.java:356) [03:21:40] [ServerMain/INFO]: [STDERR]: at io.papermc.paperclip.Paperclip.lambda$main$0(Paperclip.java:42) [03:21:40] [ServerMain/INFO]: [STDERR]: at java.base/java.lang.Thread.run(Thread.java:1583) [03:21:40] [ServerMain/INFO]: [STDERR]: Caused by: java.lang.IllegalArgumentException: No implementation of the random number generator algorithm "L64X128MixRandom" is available [03:21:40] [ServerMain/INFO]: [STDERR]: at java.base/java.util.random.RandomGeneratorFactory.findProvider(RandomGeneratorFactory.java:229) [03:21:40] [ServerMain/INFO]: [STDERR]: at java.base/java.util.random.RandomGeneratorFactory.factoryOf(RandomGeneratorFactory.java:275) [03:21:40] [ServerMain/INFO]: [STDERR]: at java.base/java.util.random.RandomGeneratorFactory.of(RandomGeneratorFactory.java:360) [03:21:40] [ServerMain/INFO]: [STDERR]: at org.dreeam.leaf.util.math.random.TheFasterRandom.(TheFasterRandom.java:17) [03:21:40] [ServerMain/INFO]: [STDERR]: ... 10 more

Dreeam-qwq commented 2 months ago

Related

Crash when using GraalVM 21 from its website

[20:07:24 INFO]: [STDERR]: java.lang.ExceptionInInitializerError
[20:07:24 INFO]: [STDERR]:      at net.minecraft.util.RandomSource.create(RandomSource.java:31)
[20:07:24 INFO]: [STDERR]:      at net.minecraft.util.RandomSource.create(RandomSource.java:16)
[20:07:24 INFO]: [STDERR]:      at net.minecraft.world.level.levelgen.WorldOptions.randomSeed(WorldOptions.java:132)
[20:07:24 INFO]: [STDERR]:      at net.minecraft.server.dedicated.DedicatedServerProperties.<init>(DedicatedServerProperties.java:172)
[20:07:24 INFO]: [STDERR]:      at net.minecraft.server.dedicated.DedicatedServerProperties.fromFile(DedicatedServerProperties.java:207)
[20:07:24 INFO]: [STDERR]:      at net.minecraft.server.dedicated.DedicatedServerSettings.<init>(DedicatedServerSettings.java:19)
[20:07:24 INFO]: [STDERR]:      at net.minecraft.server.Main.main(Main.java:135)
[20:07:24 INFO]: [STDERR]:      at org.bukkit.craftbukkit.Main.main(Main.java:356)
[20:07:24 INFO]: [STDERR]:      at io.papermc.paperclip.Paperclip.lambda$main$0(Paperclip.java:42)
[20:07:24 INFO]: [STDERR]:      at java.base/java.lang.Thread.run(Thread.java:1583)
[20:07:24 INFO]: [STDERR]: Caused by: java.lang.IllegalArgumentException: No implementation of the random number generator algorithm "L64X128MixRandom" is available
[20:07:24 INFO]: [STDERR]:      at java.base/java.util.random.RandomGeneratorFactory.findProvider(RandomGeneratorFactory.java:229)
[20:07:24 INFO]: [STDERR]:      at java.base/java.util.random.RandomGeneratorFactory.factoryOf(RandomGeneratorFactory.java:275)
[20:07:24 INFO]: [STDERR]:      at java.base/java.util.random.RandomGeneratorFactory.of(RandomGeneratorFactory.java:360)
[20:07:24 INFO]: [STDERR]:      at org.dreeam.leaf.util.math.random.TheFasterRandom.<clinit>(TheFasterRandom.java:17)
[20:07:24 INFO]: [STDERR]:      ... 10 more

1 min, wait for me to fix this:(

It relates to PaperMC/Paperclip#66 and PaperMC/Paper#10114, needs use Leaf own modified Paperclip to fix it.