Minecraft Version
Mod Loader
Both (NeoForge and Fabric)
Description

I think NoiseRouter could be optimized. My initial idea is to generate a DAG, for example from:
{
"type": "minecraft:add",
"argument1": {
"type": "minecraft:mul",
"argument1": 5,
"argument2": 7
},
"argument2": {
"type": "minecraft:mul",
"argument1": 5,
"argument2": 7
}
}
into something like this (for debugging and validation purposes):
[
{ "op": "load", "arg": 5, "idx": 0 },
{ "op": "load", "arg": 7, "idx": 1 },
{ "op": "mul", "arg1": 0, "arg2": 1, "idx": 2 },
{ "op": "add", "arg1": 2, "arg2": 2, "idx": 3 }
]
We could then generate a CompiledDenseFunction using ObjectWeb ASM or Byte Buddy and pass it to NoiseRouter (which is instantiated once per dimension). This approach could allow deduplication of repeated computations. All intermediate values could remain on the stack, avoiding excessive function calls (except for spline and possibly range_choice).
What do you think about this approach? If you're interested, I can prepare a proof of concept and evaluate its performance.
PS: Custom DenseFunctions provided by mods would still be invoked directly using invoke and can be remapped using DensityFunction.Visitor
Minecraft Version
Mod Loader
Both (NeoForge and Fabric)
Description
{ "type": "minecraft:add", "argument1": { "type": "minecraft:mul", "argument1": 5, "argument2": 7 }, "argument2": { "type": "minecraft:mul", "argument1": 5, "argument2": 7 } }into something like this (for debugging and validation purposes):
[ { "op": "load", "arg": 5, "idx": 0 }, { "op": "load", "arg": 7, "idx": 1 }, { "op": "mul", "arg1": 0, "arg2": 1, "idx": 2 }, { "op": "add", "arg1": 2, "arg2": 2, "idx": 3 } ]We could then generate a
CompiledDenseFunctionusing ObjectWeb ASM or Byte Buddy and pass it toNoiseRouter(which is instantiated once per dimension). This approach could allow deduplication of repeated computations. All intermediate values could remain on the stack, avoiding excessive function calls (except forsplineand possiblyrange_choice).What do you think about this approach? If you're interested, I can prepare a proof of concept and evaluate its performance.
PS: Custom
DenseFunctionsprovided by mods would still be invoked directly usinginvokeand can be remapped usingDensityFunction.Visitor