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 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-26 00:39:18 +01:00
parent 7092d5f4d7
commit 0a8af38ac4
2 changed files with 23 additions and 0 deletions
@@ -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 {
+20
View File
@@ -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<Self>) {
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).