Skip to content

Fix server lag from WillHandler creating empty WillChunks for every loaded chunk (#2151)#2178

Merged
wrincewind merged 1 commit intoWayofTime:1.20.1from
Saereth:1.20.1
Apr 22, 2026
Merged

Fix server lag from WillHandler creating empty WillChunks for every loaded chunk (#2151)#2178
wrincewind merged 1 commit intoWayofTime:1.20.1from
Saereth:1.20.1

Conversation

@Saereth
Copy link
Copy Markdown
Contributor

@Saereth Saereth commented Apr 22, 2026

Closes #2151.

From the discord discussion;

WillHandler.chunkLoad at src/main/java/wayoftime/bloodmagic/util/handler/event/WillHandler.java:250ish fires on every chunk load. When a chunk has no BloodMagic NBT, it falls into:

  } else {
      WorldDemonWillHandler.generateWill(event.getChunk(), (Level) event.getLevel());
  }

so generateWill (WorldDemonWillHandler.java:210) creates an empty WillChunk (base=1, empty DemonWillHolder) and puts it into the per-world ConcurrentHashMap. Every chunk unload removes it. In a server with lots of chunk churn (many players, chunk loaders, dimension hops or fast fliers), this is a constant stream of put/remove on the map for chunks that have no actual demon will activity. Which is consistent with the profiler results, should be easy enough to fix by just dropping the else { generateWill(...) } in chunkLoad. Chunks with real will NBT still flow through the if branch and everything else is lazy-loaded on demand.

Removes the automatic generation of Demon Will when a chunk is loaded without existing NBT data, preventing unintended will accumulation and hasmap pollution.
@wrincewind wrincewind merged commit 70b5547 into WayofTime:1.20.1 Apr 22, 2026
@wrincewind
Copy link
Copy Markdown
Collaborator

I only just caught that #2151 has been closed by this - i've re-opened it and marked it as 'fixed in dev'.

i'm about to be away until sunday or so, i figure we'll push a new version early next week (barring any other major bug reports that we want to tackle, or similar).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lagging the server like crazy

3 participants