graal icon indicating copy to clipboard operation
graal copied to clipboard

VectorizeSIMD flag breaks the "Iris" Minecraft modification

Open brucethemoose opened this issue 3 years ago • 4 comments
trafficstars

Describe the issue Leaving the "VectorizeSIMD" flag enabled breaks this Minecraft modification: https://github.com/IrisShaders/Iris

More specifically, passive npcs will turn invisible after some time (usually less than a minute), but only if the VectorizeSIMD flag is enabled.

Steps to reproduce the issue I can't legally redistribute Minecraft, but here are steps to replicate the environment:

  • Download or build the PolyMC launcher from here: https://github.com/PolyMC/PolyMC
  • Sign in with a valid Minecraft/Microsoft account.
  • Create a Minecraft 1.19 instance
  • Edit the instance, and install the Fabric, Sodium, and Iris mods through the UI.
  • Edit your settings to launch the game with GraalVM EE, with the following flags: -Dgraal.VectorizeSIMD=true -Dgraal.UsePriorityInlining=false
  • Start a singleplayer superflat world
  • Find a village. After some time, villagers and passive mobs will turn invisible.
  • This will not happen when Dgraal.VectorizeSIMD is set to false, or when running any other Java distribution.

Describe GraalVM and your environment:

  • GraalVM EE version 22.2.0
  • JDK major version: 17
  • OS: Windows 10 Home Edition 21H2
  • Architecture: AMD64

More details This particular bug goes back to version 22.1.0 at least. I can test older versions or help with reproduction steps if needed.

A log from the session where the bug occurred: https://mclo.gs/vNdU1Ls

Also documented here: https://github.com/IrisShaders/Iris/issues/1574

brucethemoose avatar Jul 31 '22 18:07 brucethemoose

thanks @brucethemoose we will have a look.

davleopo avatar Aug 01 '22 08:08 davleopo

Are there any narrower flags I can try? I'm looking through the output of +JVMCIPrintProperties, but I'm not sure what falls under the umbrella of VectorizeSIMD

brucethemoose avatar Aug 03 '22 14:08 brucethemoose

An interesting twist: this error seemingly requires Dgraal.UsePriorityInlining to be set to false. I can't get it to occur when it is set to true.

This is impossible to test in the current release due to #4776, but this behavior occurs in 22.1.0 and goes back to (at least) GraalVM EE 21.3.0:

invisible

@davleopo Maybe this is related to 4776, which I understand you looked at recently? Seems like quite a coincidence.

brucethemoose avatar Aug 03 '22 19:08 brucethemoose

Another possibly related rendering issue: https://github.com/HellFirePvP/AstralSorcery/issues/1963

brucethemoose avatar Aug 06 '22 06:08 brucethemoose

I think I've made a breakthrough, or at least found a better workaround. With the -Dgraal.PrintCompilation=true, I've managed to narrow down the issue to this compilation:

HotSpotCompilation-30859 Lnet/minecraft/class_4604; method_23092 (Lnet/minecraft/class_1159;Lnet/minecraft/class_1159;)V | 23493us 6666B bytecodes 7631B codesize 7566kB allocated

Those classes/methods (in Minecraft 1.19.2) are documented here:

https://maven.fabricmc.net/docs/yarn-1.19.2+build.8/net/minecraft/client/render/Frustum.html#init(net.minecraft.util.math.Matrix4f,net.minecraft.util.math.Matrix4f

https://maven.fabricmc.net/docs/yarn-1.19.2+build.8/net/minecraft/util/math/Matrix4f.html

But I am told the relevant code that is actually being run is from the Sodium mod here:

https://github.com/CaffeineMC/sodium-fabric/blob/e550fad8b38825f822d0039210f557babca15f3c/src/main/java/net/caffeinemc/sodium/mixin/core/MixinFrustum.java#L39-L44

So... Graal is compiling a Sodium matrix function with VectorizeSIMD, but it's only breaking when a mod that doesn't touch it is active? I've confirmed this does not happen with the "Iris" mod disabled. In fact, here's that same compilation with just the "Sodium" Minecraft mod enabled (and no Iris). The issue doesnt present itself here, and the same code comes out to slightly different code size:

HotSpotCompilation-26523 Lnet/minecraft/class_4604; method_23092 (Lnet/minecraft/class_1159;Lnet/minecraft/class_1159;)V | 23759us 6666B bytecodes 7628B codesize 7468kB allocated

And I'll repeat the repro steps to be clear:

  • Install Minecraft 1.19.2, and run it with GraalVM 22.2.0 with UsePriorityInlining disabled.
  • Install the Fabric, Sodium, and Iris mods (which is easiest to do on linux with the PolyMC launcher).
  • Create a singleplayer creative world with the world type "superflat", and walk to a village.
  • Watch villagers. After some time (usually less than 2 minutes), they will turn invisible.
  • They will not disappear with VectorizeSIMD disabled.
  • They will also not disappear with the following flag: -Dgraal.GraalCompileOnly=~*.*class_4604*.*

If there's anything you need that could help (perhaps a some kind of dump?), please let me know.

brucethemoose avatar Aug 25 '22 01:08 brucethemoose

I have narrowed down the bug and realized I am off track here, so I am going to close this issue and start a new one with more concise information.

brucethemoose avatar Aug 27 '22 20:08 brucethemoose