From 0a8af38ac4ed1094a871eacae8338c4b95c636d5 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Mon, 26 Oct 2026 00:39:18 +0100 Subject: [PATCH] Rings: search them on a thread behind the server, as the world opens The previous commit decides chunks far from the rings without them. The 128 biome searches now start on a helper thread as an overworld with structures opens, behind the server and render threads, so an eye of ender or a chunk near a ring finds them done or shares what is left, instead of running them all on the thread that asked. Co-Authored-By: Claude Opus 5.5 --- .../horizon-client/src/game/world_loading.rs | 3 +++ crates/horizon-client/src/vanillagen.rs | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/crates/horizon-client/src/game/world_loading.rs b/crates/horizon-client/src/game/world_loading.rs index 998788960..0cea31fd0 100644 --- a/crates/horizon-client/src/game/world_loading.rs +++ b/crates/horizon-client/src/game/world_loading.rs @@ -246,6 +246,9 @@ pub(super) fn make_streaming( let inner = Arc::new(VanillaTerrain::for_world(&options.resources.join("worldgen"), pack.assets.registry, res.biomes(), seed, dim.id(), structures).map_err(|e| { format!("{e}\nPrepare the worldgen bundle with the launcher, or: horizon-prepare --prepare") })?); + if dim == Dim::Overworld && structures { + inner.search_rings_behind(); + } locator = Some(inner.clone()); Streaming::new( Arc::new(Persistent { diff --git a/crates/horizon-client/src/vanillagen.rs b/crates/horizon-client/src/vanillagen.rs index a17bb22d3..046de6551 100644 --- a/crates/horizon-client/src/vanillagen.rs +++ b/crates/horizon-client/src/vanillagen.rs @@ -279,6 +279,26 @@ impl VanillaTerrain { let worker = worker.get_or_insert_with(|| self.generator.worker()); worker.ring_positions(set) } + /// Searches the concentric rings on a thread of their own, behind the + /// server and render threads, as vanilla's background executor does: + /// the first chunks don't wait for them, and an eye of ender thrown + /// later finds them ready. A chunk or a query that needs them first + /// shares the remaining searches with this thread. + pub fn search_rings_behind(self: &Arc) { + let terrain = Arc::clone(self); + let spawned = std::thread::Builder::new() + .name("Ring search".into()) + .spawn(move || { + horizon_threads::behind_server(); + let _ = terrain + .generator + .worker() + .ring_positions("minecraft:strongholds"); + }); + if let Err(e) = spawned { + log::warn!("ring search thread: {e}"); + } + } } /// The worldgen bundle at `dir`, loaded once and shared by every generator /// and by live feature placement (sapling growth, bone meal).