Chunker 1.21.11
Highlights
- CPU + memory optimization for high chunk throughput.
- Chunk position keys are now packed
(x,z)longs instead of true Morton interleaving. - Player chunk tracking was rewritten to avoid expensive scans and reduce allocations.
- Less GC pressure during heavy pre-generation runs, especially on high end CPUs.
Why this update?
Chunker was using Morton codes as chunk keys, but the plugin never sorts or iterates keys in Morton order (some old code that was carried over from old changes). So the Morton bit interleave math was pure overhead. This release switches to a packed long key and removes a bunch of object churn in hot paths.
Performance changes
Packed long chunk keys
Chunk keys are now generated like this:
key = ((long)x << 32) | (z & 0xFFFFFFFFL)
This is faster than Morton encoding and still guarantees uniqueness for (x,z).
ChunkPos cache no longer boxes longs
- Removed
Cache<Long, ChunkPos>usage to avoidLongboxing. - Added a small bounded primitive long ->
ChunkPoscache. - This reduces allocations and GC spikes during high chunk rates.
Player chunk tracking: refcounted + primitive keys
Player tracking used to do a stream scan across every player's chunk set to see if a chunk was still occupied. That got expensive fast.
Now Chunker uses:
- A primitive
longset per player - A refcount map for chunk occupancy
- A single membership set of currently occupied chunks
This removes stream allocations and avoids scanning every player set.
New chunk pinning preserved
Chunker previously treated newly generated chunks as "do not unload". This behavior is still preserved by tracking newly generated chunk keys separately.
Updated classes
MortonCode- Replaced Morton interleave encoding with packed long chunk keys.
ChunkPos- Removed Guava cache and added a primitive long cache.
PreGenerationTask- Switched player chunk tracking to fastutil primitive sets/maps.
- Added new-chunk pin tracking.
PlayerEvents- Rewritten to use long keys + refcount logic (no stream scans).
PreGenerator- ChunkLoad handling updated for primitive keys + pinned chunks.
- Cleanup/shutdown clears new tracking structures under lock.
Version
- Bump plugin version to
1.21.11