Skip to content

AsmHandler.overrideLightValue causes significant overhead when used alongside Alfheim #53

@Userrr67

Description

@Userrr67

Mods:

  • Quantum Things
  • Alfheim (lighting engine replacement)

Description:
AsmHandler.overrideLightValue() hooks into Block.getLightValue() via ASM bytecode injection. Because Alfheim calls getLightValue() on every single block during its light propagation passes, the Random Things ASM hook runs on every one of those calls, adding measurable overhead to every lighting calculation in the game.

Additionally, RTEventHandler.notifyNeighbors() is being triggered as a side effect of lighting updates, which causes further unnecessary work.

Profiler trace:

dev.redstudio.alfheim.lighting.LightUtil.getLightValueForState() 1.43%
  net.minecraft.block.Block.getLightValue() 1.38%
    lumien.randomthings.handler.AsmHandler.overrideLightValue() 1.01%
      lumien.randomthings.handler.AsmHandler.overrideLightValueServer() 0.44%

lumien.randomthings.handler.RTEventHandler.notifyNeighbors() 0.15%
lumien.randomthings.handler.AsmHandler.overrideFallThrough() 0.09%

The overrideLightValue hook alone accounts for ~1% of total server CPU time, purely as overhead on Alfheim's lighting passes.

Expected behavior:
The ASM hook should ideally be a no-op or skip quickly when the block has no Random Things-specific light override, to avoid adding cost to every lighting calculation from other mods.

Possible fix:
An early-exit check in overrideLightValue before doing any meaningful work, e.g. checking if the block is registered with Random Things' light override system before proceeding, would eliminate most of the overhead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions