r/rust_gamedev • • 5d ago

I'm experimenting with multithreaded Minecraft entity ticking in Rust

Hey everyone!

I've been working on a project called Voxaryn, based on the open-source Rust Minecraft project Horizon.

My goal is to explore how much of Minecraft's server-side simulation can actually be parallelized across CPU cores without breaking game behavior.

So far, I've been experimenting with parallel entity ticking using Rayon.

The basic idea is to group interacting entities into independent "islands" and process those groups on separate threads.

In some controlled experiments, this showed promising results, including up to 3.9x speedup for the parallelized workload with 12 threads.

But things get much more complicated when entities are densely packed together.

For example, testing 2,000 cows in one dense group creates a completely different situation compared to splitting them across eight separate pens.

When many entities interact with each other, splitting the workload becomes much harder, and simply adding more threads doesn't solve the problem.

I've also been working on deterministic correctness checks and reproducible benchmarks, because performance improvements mean nothing if the simulation starts behaving differently.

I use AI coding agents extensively for implementation and testing, while focusing on directing experiments, reviewing results, and understanding the technical decisions.

The project is still experimental, and there's a lot left to figure out.

I'm sharing it because I'd love to hear from people with experience in parallel game loops, ECS architectures, or multithreaded simulation.

How would you approach parallelizing entity updates when many entities depend on each other?

GitHub (experimental P2.5 branch with more recent implementation and research):
https://github.com/1wairesd/Voxaryn/tree/experimental/entity-islands-p2.5

The main branch is currently behind the experimental development work.

I'm planning to keep sharing progress, experiments, and failures as I continue working on it.

1 Upvotes

2 comments sorted by

1

u/garrett_d_null_ptr 4d ago

If you're hitting contention walls with Rayon, look into using message-passing (like crossbeam channels) for entity state updates instead of shared mutable references. I've found that approach works well in my identity verification work to avoid lock contention.

1

u/bcamanitu 1d ago

How does Minecraft currently handle it when large numbers of entities depend on each other? Does it update every single entity all in the same tick? Does it check every entity against every other nearby entity? Im guessing no because that would slow to a crawl. So id start by learning how exactly the current tick manages and culls entities to update. If it uses any sort of double buffer then you're in luck because thats easily parallelizable. If not then you may need to look into some distributed computing algorithms and existing parallel algorithms. Id imagine it boils down to a few passes where you first find each entities dependencies and extract the needed state,then create a bunch of update jobs that update all entities based on their dependencies.

Basically, if you can treat the next tick state as a function from each entity + its dependencies state from the most recent tick, then you don't have to propagate any changes rhat occur in this tick to further entities. Thats how it should work, but i didnt design Minecraft so I dont know if they allow multiple mutations per tick. Id sure hope not, otherwise a tick is kinda meaningless.