Skip to content

perf: fastutil Long2ObjectOpenHashMap for PlayerMap, zero-allocation ConcurrentIntHashMap, and Java 9-25 timings support - #165

Open
GamingOP69 wants to merge 6 commits into
Wind-Development:masterfrom
GamingOP69:perf/playermap-and-timings-java-compat
Open

perf: fastutil Long2ObjectOpenHashMap for PlayerMap, zero-allocation ConcurrentIntHashMap, and Java 9-25 timings support#165
GamingOP69 wants to merge 6 commits into
Wind-Development:masterfrom
GamingOP69:perf/playermap-and-timings-java-compat

Conversation

@GamingOP69

Copy link
Copy Markdown

Summary

Optimizes PlayerMap spatial lookup performance, eliminates lambda allocations on ConcurrentIntHashMap, synchronizes explosion density caching, fixes async pathfinding rejection recovery, and adds Java 9–25 version parsing support in CustomTimingsHandler.

Problem & Root Cause

  • PlayerMap used Long2ObjectArrayMap, which performs $O(N)$ linear scans per bucket. On servers with large player counts, this degraded performance. Additionally, calling move() before add() caused NullPointerException on uninitialized buckets.
  • ConcurrentIntHashMap created unnecessary lambda instances on hot get/put paths in the entity tracker.
  • explosionDensityCache in World.java was accessed without synchronization by async TNT calculations.
  • In SearchHandler.java, if the async pathfinding executor rejected a task (e.g. queue full), isSearching was never reset, permanently freezing mob navigation.
  • CustomTimingsHandler parsed Java versions assuming a single-digit major version format (1.8), which broke on modern Java runtimes (Java 9, 11, 17, 21, 25).

Solution

  • Upgraded PlayerMap to Long2ObjectOpenHashMap for $O(1)$ lookups and added bucket presence checks in move().
  • Replaced lambda allocations in ConcurrentIntHashMap with direct synchronized methods.
  • Added synchronization to explosionDensityCache operations.
  • Wrapped async pathfinding task submission with proper isSearching cleanup on rejection.
  • Updated CustomTimingsHandler to parse modern JRE version strings (11.0.x, 17.0.x, 21.0.x, 25.x).
  • Added unit tests: PlayerMapRegressionTest, IndexedLinkedHashSetRegressionTest, ConcurrentIntHashMapRegressionTest, ExplosionDensityCacheConcurrencyTest, JavaVersionParsingTest, and JavaVersionParsingRegressionTest.

…ConcurrentIntHashMap, and Java 9-25 timings support
@GamingOP69
GamingOP69 force-pushed the perf/playermap-and-timings-java-compat branch from d4d5c5e to 6ad242a Compare August 19, 2026 17:40
@GamingOP69

Copy link
Copy Markdown
Author

A few performance improvements and a Java compatibility fix.

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.

1 participant