diff --git a/crates/horizon-client/src/benchmark.rs b/crates/horizon-client/src/benchmark.rs index bcb94589c..12e38e78a 100644 --- a/crates/horizon-client/src/benchmark.rs +++ b/crates/horizon-client/src/benchmark.rs @@ -323,10 +323,15 @@ const QUIET_MESHES_PER_S: f64 = 100.0; /// happened (`tools/perf_bench.py`'s `wait_loaded`). With `status.streaming`, the sections are /// drawn once no stage has held work for half a second: blocks changing after the load (fluids /// settling, random ticks) only remesh in bursts. Without it, meshing has to go quiet. +/// +/// Right after a teleport (and at spawn) the game reports nothing queued and steady counts for over +/// a second before it starts loading: the counts must change once, or stay full for 5 s, and the +/// resident chunks reach [`view_chunks`], before "steady" means loaded. fn wait_loaded(control: &Control, near: impl Fn(&Value) -> bool) -> Result { let deadline = Instant::now() + LOAD_LIMIT; let (mut last, mut changed, mut meshing) = (None, Instant::now(), Instant::now()); let mut previous: Option<(Instant, f64)> = None; + let (mut first, mut moved, began) = (None, false, Instant::now()); while Instant::now() < deadline { let s = control.status(); let now = Instant::now(); @@ -339,6 +344,19 @@ fn wait_loaded(control: &Control, near: impl Fn(&Value) -> bool) -> Result 0 + && resident >= min_chunks + && now - began > Duration::from_secs(5)); + if min_chunks > 0 && (!moved || resident < min_chunks) { + (last, changed, previous, meshing) = (None, now, None, now); + thread::sleep(Duration::from_millis(50)); + continue; + } if last != Some(counts) { (last, changed) = (Some(counts), now); } @@ -370,6 +388,12 @@ fn wait_loaded(control: &Control, near: impl Fn(&Value) -> bool) -> Result u64 { + (0.8 * std::f64::consts::PI * (distance * distance) as f64) as u64 +} + /// Vanilla's yaw facing from `start` to `end`. fn yaw(start: [f64; 3], end: [f64; 3]) -> f64 { (-(end[0] - start[0])).atan2(end[2] - start[2]).to_degrees() @@ -420,6 +444,13 @@ mod tests { assert!(scenes("nether").is_none()); } + #[test] + fn view_chunks_matches_perf_bench() { + assert_eq!(view_chunks(12), 361); + assert_eq!(view_chunks(32), 2573); + assert_eq!(view_chunks(0), 0); + } + #[test] fn yaw_matches_vanilla() { // South (+Z) is 0, west (-X) 90, east (+X) -90.