Skip to content

Tick Time Expensive with StellarFarmlandBlock#isStarlit #10

@ByThePowerOfScience

Description

@ByThePowerOfScience

Specs

Mod Version: neoforge-mc1.21.1-0.2.0.3
Neoforge Version: 21.1.219
Side: Dedicated Server

Description

I'm getting a good amount of compute taken up by NaturalSpawnerMixin and what it invokes, despite having very few mob spawns:

private static void operation_starcleave$starlitAreasSpawnOverride(ServerLevel level, StructureManager structureManager, ChunkGenerator generator, MobCategory category, BlockPos pos, Holder<Biome> biome, CallbackInfoReturnable<WeightedRandomList<MobSpawnSettings.SpawnerData>> cir) {
Firmament firmament = Firmament.fromLevel(level);
if (firmament != null) {
if (StellarFarmlandBlock.isStarlit(level, pos, firmament)) {
switch(category) {
case MONSTER:
cir.setReturnValue(FirmamentMobSpawning.STARLIGHT_MONSTERS);
break;
case CREATURE:
case AMBIENT:
cir.setReturnValue(FirmamentMobSpawning.NOSPAWNS);
break;
}
}
}
}

Here's the relevant section of the Spark report:

Image

Suggested Fix

Looking at the code, I don't see any major optimization pitfalls. Something you might want to look into is saving the damage as a "potential field", though I'm pretty sure that would only save on memory and not compute time.

I think some caching, so it doesn't re-check blocks that have been checked already, is all it needs to fix the issue.

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