Gollorum / Signpost

minecraft forge signpost mod
15 stars 11 forks source link

VillageSignpost::fetchPossibleTargets causes high thread contention #102

Open TranslationLookasideBuffer opened 1 year ago

TranslationLookasideBuffer commented 1 year ago

Issue

While a player is loading pregenerated chunks, Signpost (v1.19.2-2.01.0) consumes a large amount of server time calls to net.minecraft.util.thread.BlockableEventLoop.waitForTasks():

Server thread [102.27ms]
gollorum.signpost.utils.__Delay_onServerTick_ServerTickEvent.invoke() [102.13ms]
gollorum.signpost.utils.Delay.onServerTick() [102.13ms]
gollorum.signpost.utils.Delay$Task.run() [102.13ms]
gollorum.signpost.minecraft.block.tiles.PostTile$$Lambda$26051/0x000000080376ad68.run() [102.13ms]
gollorum.signpost.minecraft.block.tiles.PostTile.lambda$setLevel$8() [102.13ms]
gollorum.signpost.minecraft.worldgen.VillageSignpost.populate() [102.12ms]
gollorum.signpost.minecraft.worldgen.VillageSignpost.fetchPossibleTargets() [102.11ms]
java.util.stream.ReferencePipeline.collect() [102.11ms]
java.util.stream.AbstractPipeline.evaluate() [102.11ms]
java.util.stream.ReduceOps$ReduceOp.evaluateSequential() [102.11ms]
java.util.stream.AbstractPipeline.wrapAndCopyInto() [102.11ms]
java.util.stream.AbstractPipeline.copyInto() [102.11ms]
java.util.stream.Sink$ChainedReference.end() [102.11ms]
java.util.stream.Sink$ChainedReference.end() [102.11ms]
java.util.stream.Sink$ChainedReference.end() [102.11ms]
java.util.stream.Sink$ChainedReference.end() [102.11ms]
java.util.stream.SortedOps$RefSortingSink.end() [102.11ms]
java.util.ArrayList.forEach() [102.11ms]
java.util.stream.SortedOps$RefSortingSink$$Lambda$497/0x0000000800df65f0.accept() [102.11ms]
java.util.stream.ReferencePipeline$3$1.accept() [102.11ms]
java.util.stream.ReferencePipeline$2$1.accept() [102.11ms]
gollorum.signpost.minecraft.worldgen.VillageSignpost$$Lambda$26369/0x00000008037bd018.test() [102.11ms]
gollorum.signpost.minecraft.worldgen.VillageSignpost.lambda$fetchPossibleTargets$4() [102.11ms]
gollorum.signpost.WaystoneLibrary.contains() [102.11ms]
gollorum.signpost.WaystoneLibrary.assertTileEntityExists() [102.11ms]
net.minecraft.world.level.CommonLevelAccessor.getBlockEntity() [102.11ms]
net.minecraft.world.level.BlockGetter.getBlockEntity() [102.11ms]
net.minecraft.world.level.Level.getBlockEntity() [102.11ms]
net.minecraft.world.level.Level.getChunkAt() [102.11ms]
net.minecraft.world.level.Level.getChunk() [102.11ms]
net.minecraft.world.level.Level.getChunk() [102.11ms]
net.minecraft.server.level.ServerChunkCache.getChunk() [102.11ms]
net.minecraft.server.level.ServerChunkCache.getChunkBlocking() [102.11ms]
net.minecraft.util.thread.BlockableEventLoop.managedBlock() [101.87ms]
net.minecraft.util.thread.BlockableEventLoop.waitForTasks() [92.99ms]
java.util.concurrent.locks.LockSupport.parkNanos() [91.51ms]
jdk.internal.misc.Unsafe.park() [91.51ms]

In short, I think what's going on is there is a large number of villages within some radius and VillageSignpost.populate is kicking off with a large list of possible targets which in turn causes assertTileEntityExists to be called which has a strong dependency on some blocking code.

This causes pauses on the order of a minute which disconnects players.

Detailed Server Info

Expand Me ### State (Spark Profile) * The platform is a Forge server running version "43.1.57". * The detected Minecraft version is "1.19.2". * The server is running in online mode. * The system is running Windows 10 Pro (amd64) version "10.0.19045" and has 8 CPU threads available. * The CPU is described as an Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz. * The process is using Java 17.0.5 (unknown from Oracle Corporation). * The profiler was running for 1m 20s (519 ticks). ### World 6500 x 6500 blocks (~165,000 chunks) Pregenerated with Chunky. There are multiple mods that create new "villages". e.g. Minecolonies (though these are always empty due to a datapack). ### Full Modlist * additional_lights (v2.1.5) * additionaladditions (v5.1.0) * additionalstructures (v4.0.2) * advancedperipherals (v0.7.22b) * ae2 (v12.9.1) * alexsdelight (v1.4) * alexsmobs (v1.21.1) * another_furniture (v2.1.2-1.19.2) * appmek (v1.3.3) * aquaculture (v1.19.2-2.4.8) * architectury (v6.3.56) * attributefix (v17.1.2) * autoreglib (v1.8.2-55) * badpackets (v0.2.1) * balm (v4.5.3) * betterdeserttemples (v1.19.2-Forge-2.2.1) * betterdungeons (v1.19.2-Forge-3.2.2) * bettermineshafts (v1.19.2-Forge-3.2.0) * betteroceanmonuments (v1.19.2-Forge-2.1.0) * betterstrongholds (v1.19.2-Forge-3.2.0) * betterwitchhuts (v1.19.2-Forge-2.1.0) * biomemakeover (v1.19.2-1.6.2) * blockui (v1.19-0.0.64-ALPHA) * blue_skies (v1.3.20) * blueprint (v6.1.0) * bookshelf (v16.1.11) * caelus (v1.19.2-3.0.0.6) * canary (v0.1.3) * carryon (v1.18.2.5) * chickenchunks (v2.9.4.97) * chunky (v1.3.38) * citadel (v2.1.1) * cloth_config (v8.2.88) * clumps (v9.0.0+14) * codechickenlib (v4.3.0.470) * collective (v5.25) * comforts (v6.0.3+1.19.2) * computercraft (v1.101.1) * connectedglass (v1.1.4b) * corpse (v1.19.2-1.0.0) * create (v0.5.0.f) * createaddition (v1.19.2-20221124a) * createdeco (v1.2.11-1.19.2) * creativecore (v2.9.3) * cucumber (v6.0.3) * curios (v1.19.2-5.1.1.0) * darkutils (v13.1.2) * decorative_blocks (v3.0.0) * deeperdarker (v1.1.3) * delightful (v3.1.4) * diagonalfences (v4.2.3) * domum_ornamentum (v1.19-1.0.75-ALPHA) * duckling (v2.0.8) * dungeoncrawl (v2.3.11) * easyanvils (v4.0.6) * easymagic (v4.3.2) * ecologics (v2.1.10) * effective_fg (v1.3.4) * elytraslot (v6.0.0+1.19.2) * engineersdecor (v1.3.27) * fairylights (v6.0.0) * farmersdelight (v1.19-1.2.0) * farmersrespite (v1.19-2.0) * fastleafdecay (v30) * flywheel (v0.6.7-8) * forge (v43.1.57) * framedblocks (v6.6.2) * geckolib3 (v3.1.38) * goblintraders (v1.8.0) * guardvillagers (v1.19.2-1.5.2) * hunterillager (v1.19.2-6.2.0) * immersiveengineering (v1.19.2-9.0.0-153) * incendium (v5.1.4) * infernalexp (v2.5.1) * mcjtylib (v1.19-7.0.6) * mekanism (v10.3.5) * mekanismgenerators (v10.3.5) * mekanismtools (v10.3.5) * minecolonies (v1.19.2-1.0.1135-ALPHA) * minecraft (v1.19.2) * moonlight (v1.19.2-2.1.15) * multipiston (v1.19.2-1.2.21-ALPHA) * mysticalagriculture (v6.0.5) * naturalist (v2.1.1) * naturescompass (v1.19.2-1.10.0-forge) * nethersdelight (v1.19-3.0) * nochatreports (v1.19.2-v1.5.1) * nullscape (v0.0NONE) * openpartiesandclaims (v0.16.5) * oreexcavation (v1.11.166) * paragon (v1.0.3) * pigpen (v11.1.2) * puzzleslib (v4.3.12) * quark (v3.3-374) * rftoolsbase (v1.19.1-4.0.3) * runelic (v14.1.2) * saturn (v0.0.1) * Server thread0.01% * signpost (v1.19.2-2.01.0) * simplylight (v1.19.2-1.4.5-build.42) * smoothchunk (v1.19.1-2.0) * snowundertrees (v1.3) * sophisticatedbackpacks (v1.19.2-3.18.35.751) * sophisticatedcore (v1.19.2-0.5.32.181) * spark (v1.10.17) * spectrelib (v0.10.0+1.19) * structory (v1.0.1) * structure_gel (v2.7.1) * structurize (v1.19.2-1.0.468-ALPHA) * supplementaries (v1.19.2-2.2.26) * t_and_t (v1.10) * takesapillage (v1.0.2) * terrablender (v2.0.1.128) * terralith (v0.0NONE) * torchmaster (v19.2.0) * twigs (v2.0.1+1.19) * villagernames (v4.3) * waila (v5.13.4) * waystones (v11.1.0) * woodworks (v2.1.0) * wthit (v5.13.4) * xnet (v1.19-5.0.2) * xnetgases (v4.0.0) * yungsapi (v1.19.2-Forge-3.8.2) * yungsextras (v1.19.2-Forge-3.1.0)