Skip to content

Optimize NoiseRouter #175

@adiantek

Description

@adiantek

Minecraft Version

Mod Loader

Both (NeoForge and Fabric)

Description

Image 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions