Skip to content

ft: parallel entity processing optimizations and stability fixes#14

Open
Xytronix wants to merge 1 commit intoIroriPowered:masterfrom
Xytronix:ft-parallelism-improvements
Open

ft: parallel entity processing optimizations and stability fixes#14
Xytronix wants to merge 1 commit intoIroriPowered:masterfrom
Xytronix:ft-parallelism-improvements

Conversation

@Xytronix
Copy link
Contributor

Summary

Adds parallel entity processing optimizations and stability fixes for high-entity-count servers.

Type of change

  • Bug fix (non-breaking)
  • New feature (non-breaking)
  • Breaking change (requires documentation/migration)
  • Chore / refactor
  • Documentation only

Implementation details

  • MixinTickingThread (isInThread() relaxation): Overrides isInThread() to return true for ForkJoinWorkerThreads belonging to ForkJoinPool.commonPool(). Without this, parallel entity ticking deadlocks: the world thread blocks waiting for pool tasks, while pool tasks try to bounce World method calls (chunk lookups, player queries) back to the blocked world thread via supplyAsync(..., this).join().
  • MixinSpatialSystem: Replaces the sequential forEachChunk position collection in SpatialSystem.tick() with parallel per-chunk collection into thread-local buffers, followed by sequential merge into SpatialData. It falls back to sequential for ≤2 chunks.
  • ParallelSpatialCollector: Utility that submits per-chunk collection tasks to ForkJoinPool.commonPool(), collects (position, ref) pairs into local lists, then merges into SpatialData sequentially.
  • MixinSteeringSystem: Enables isParallel() for SteeringSystem. It is gated behind a threshold (default 64) and is safe production, but can cause a crash if debugging enabled (non-atomic save).
  • MixinEntityViewer: Silently drops queueUpdate/queueRemove calls for entities not in the visibility set, instead of throwing IllegalArgumentException (which disconnects the player).
  • WatchDog optimisation: prevented crash by removing Universe.get().getDefaultWorld() from constructor if universe is not ready, adds null guards on watchdogThread.interrupt() in unregisterService(), lastDefaultWorld.getName() in start() and fixes integer division for timeout logging.

Checklist

  • Code compiles successfully
  • Pull request does not contain unrelated changes
  • Changes follow this project's code style (use spotlessApply when necessary)
  • Changes are tested or will be tested after submission

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