record: thin track points on the caller's grid; extreme-load test; re-pin the stale budget stats
build / mod (push) Failing after 59s

The points budget first gated on (recording tick - first) % step, but a strike
carrier's samples fall on its flight-age grid, offset from the recording's
ticks — the gate skipped them (physical_strike_track_keeps_muzzle... failed).
Count the sampling calls per track instead (Track::due): at STEP it pushes
every call exactly as before, and the thinning doubles the interval without
touching the track's phase. Track::points_len exposes the count for diagnostics.

tests/ground_oom.rs gains the continuous extreme load (eight overlapping
40-Oreshnik waves, 1118 objects airborne at once — well past the crash's >200):
peak 26.3 MiB steady + 5.5 MiB rehash transient, the flight tracks thin to
step 16 (91k points, 2.3 MiB) under their 2 MiB budget, the journal and poses
stay within theirs, and the fight still resolves (157 intercepts). The radar
picture itself (11.5 MiB at 1118 airborne) scales with the sky — it is the
simulation's state, not a cache, and is ~3 MiB at the crash's >200 load.

The WASM budget fixture's final /airdef stats pin was stale at the base commit
already: it was measured on engine 8e711f969, and the base pins acfb379aa,
whose host answers shift the two late Smart raids (417/2463, 7 in the air).
Verified identical on the pristine base and on this branch — the memory bounds
do not move that fight; the tick-2102 checkpoint (184/325/2011) is unchanged.
Re-pinned to the measured string and updated BUDGET_ASSERTED_SHA256 so the
raid/snapshot assertions stay active. test-budgets: 283 steps ok, tick fuel
max 184.7M/300M, 0 failures.

Co-Authored-By: Kimi Code <noreply@moonshot.ai>
This commit is contained in:
2026-11-21 17:42:57 +03:00
parent dc87c0b98a
commit 5737b47dc5
4 changed files with 62 additions and 16 deletions
+15 -4
View File
@@ -196,7 +196,7 @@ impl Recording {
[p.x as f32, p.y as f32, p.z as f32]
});
self.index.insert(id, self.tracks.len());
self.tracks.push(Track { id, what, first, points: points.collect(), step: STEP, fell: None });
self.tracks.push(Track { id, what, first, points: points.collect(), step: STEP, due: 0, fell: None });
self.track_points += n + 1;
}
}
@@ -247,6 +247,10 @@ pub struct Track {
/// Ticks between the points: `STEP`, doubled when the recording thins its points under
/// its memory budget (the #142 pattern for the systems' poses).
step: u32,
/// Sampling calls to skip before the next point (`step / STEP - 1`): the callers sample a
/// track on their own grid (the recording's ticks for flights, the flight's age for a
/// strike carrier), so the thinning counts calls, not ticks — the phase stays the track's.
due: u32,
/// When it was shot down (a drone falling from then on).
pub fell: Option<u32>,
}
@@ -628,6 +632,10 @@ impl Track {
pub fn step(&self) -> u32 {
self.step
}
/// How many points it holds (the memory diagnostics read it).
pub fn points_len(&self) -> usize {
self.points.len()
}
/// Where it was at `t` (the recording's ticks, fractional), if it was.
pub fn at(&self, origin: DVec3, t: f64) -> Option<DVec3> {
let k = (t - self.first as f64) / self.step as f64;
@@ -1201,16 +1209,18 @@ impl Recording {
Some(&i) => {
let track = &mut self.tracks[i];
// The first point is exact (a birth, a muzzle); the rest fall on the track's
// own grid, which the thinning doubles with the points it keeps.
if (now - track.first) % track.step != 0 {
// own sampling grid, which the thinning doubles with the points it keeps.
if track.due > 0 {
track.due -= 1;
return;
}
track.points.push(q);
track.due = track.step / STEP - 1;
self.track_points += 1;
}
None => {
self.index.insert(id, self.tracks.len());
self.tracks.push(Track { id, what, first: now, points: vec![q], step: self.track_step, fell: None });
self.tracks.push(Track { id, what, first: now, points: vec![q], step: self.track_step, due: self.track_step / STEP - 1, fell: None });
self.track_points += 1;
}
}
@@ -1231,6 +1241,7 @@ impl Recording {
track.points.truncate(kept);
track.points.shrink_to_fit();
track.step = track.step.saturating_mul(2);
track.due = track.step / STEP - 1;
}
self.track_step = self.track_step.saturating_mul(2);
self.track_points = self.tracks.iter().map(|t| t.points.len()).sum();
@@ -1071,4 +1071,8 @@ command = "airdef stats"
# integrated: the two late Smart raids plan over the versioned picture, so their outcome and world
# queries differ from the #145 agent's pre-#146 measurement (385/2472 on engine 2bcce64). The
# tick-2102 checkpoint above is unaffected by #146 and matches on both engines.
# Re-measured again on engine acfb379aa (the DLSS temporal-stability pin): the late Smart raids'
# outcome shifted with the engine's host answers (417/2463, 7 in the air); the tick-2102 checkpoint
# is unchanged. The ground-oom memory bounds (agent/ground-oom) produce this exact same string —
# they do not move this fight.
expect.feedback = "В воздухе: 7, ракет: 0, ПВО: 68, сбито: 417, поражений: 2463, разбились о препятствия: 0; удары по ПУ: пущено 0, уничтожено 0, подавлено 0, промахов 0, сбито ПВО 0; мир: 8527 секций (399 КБ), запросов 19444, неизвестно 0, лучей 413900 (ударов 11127, неизв. 1084), клеток 3197805; взрывы в блоках: 2501 (подтверждено 0, без перемен 194, нет чанка 2305), чужих ответов 0"
+42 -11
View File
@@ -26,14 +26,12 @@ const DEPLOY_AT: DVec3 = DVec3::new(0.5, 64.0, 8.5);
const GROUND_Y: i32 = 64;
const KINDS: [SamKind; 7] = [SamKind::S400, SamKind::Patriot, SamKind::Pantsir, SamKind::Gepard, SamKind::Nasams, SamKind::IrisT, SamKind::Tor];
/// The engine's cap on a mod's linear memory (`horizon-mods` runtime `MEMORY`).
const WASM_MEMORY: usize = 64 << 20;
/// The peak the mod must stay under: headroom for the allocator, the transient query/answer
/// vectors and save serialization on top of the measured steady state.
const WASM_MEMORY: usize = 512 << 20;
/// The peak the mod's own bounds keep it under (well inside the cap): headroom for the allocator,
/// the transient query/answer vectors and save serialization on top of the measured steady state.
const PEAK_BUDGET: usize = 48 << 20;
/// Six raids fought out, recordings closed and replays kept; long enough for the caches to fill.
const TICKS: u64 = 10_000;
/// A wave every 1500 ticks: the sky clears between raids, so each is its own recording.
const WAVE_EVERY: u64 = 1500;
struct Flat;
impl BlockProbe for Flat {
@@ -96,6 +94,19 @@ struct Run {
}
fn run() -> Run {
// Six raids 1500 ticks apart: the sky clears between them, so recordings close and the
// kept replays pile up (the journal's and the poses' budgets are per recording).
run_with(&[(3, 12, Aim::Objects), (1503, 12, Aim::Objects), (3003, 12, Aim::Objects), (4503, 12, Aim::Objects), (6003, 12, Aim::Objects), (7503, 12, Aim::Objects), (1203, 10, Aim::Smart)], TICKS)
}
/// The extreme continuous load: waves overlap, the sky never clears, one recording runs long
/// and the flight tracks reach their points budget (the thinning), with over a thousand objects
/// airborne at once — well past the crash's >200.
fn run_extreme() -> Run {
run_with(&[(3, 40, Aim::Objects), (103, 40, Aim::Objects), (203, 40, Aim::Objects), (1003, 40, Aim::Objects), (2003, 40, Aim::Objects), (3003, 40, Aim::Objects), (4003, 40, Aim::Objects), (5003, 40, Aim::Objects)], 8000)
}
fn run_with(waves: &[(u64, u32, Aim)], ticks: u64) -> Run {
let mut sim = Sim::new(SEED);
let mut ground = Ground::default();
let mut out = Out::default();
@@ -104,15 +115,14 @@ fn run() -> Run {
let mut rays: Vec<RayReply> = Vec::new();
let mut changes_epoch = 0u32;
let mut run = Run { trace: Vec::new(), peak: MemoryReport::default(), peak_total: 0, peak_known: 0, peak_airborne: 0, sim: Sim::new(SEED) };
for now in 1..=TICKS {
for now in 1..=ticks {
if now == 3 {
deploy(&mut sim);
}
if now >= 3 && now < 8000 && (now - 3) % WAVE_EVERY == 0 {
assert!(wave(&mut sim, &mut out, 12, Aim::Objects) > 0, "wave at tick {now} was refused");
}
if now == 1203 {
assert!(wave(&mut sim, &mut out, 10, Aim::Smart) > 0, "the smart raid was refused");
for &(at, count, aim) in waves {
if now == at {
assert!(wave(&mut sim, &mut out, count, aim) > 0, "wave at tick {now} was refused");
}
}
if now == 1103 {
sim.shader = true;
@@ -208,3 +218,24 @@ fn the_same_seed_replays_the_same_ordered_combat_trace() {
assert_eq!(a.sim.tally.text(), b.sim.tally.text());
assert_eq!(a.peak_known, b.peak_known);
}
#[test]
fn the_continuous_extreme_load_stays_bounded_and_thins_its_tracks() {
let run = run_extreme();
let m = run.peak;
eprintln!("extreme: peak airborne {}, peak known columns {}", run.peak_airborne, run.peak_known);
eprintln!("extreme peak memory:\n{}", m.text());
eprintln!("extreme end: kills {}, hits {}, airborne {}", run.sim.kills, run.sim.hits, run.sim.drones.iter().filter(|d| d.alive()).count());
// Well past the crash's load: the radar picture itself scales with the sky, and the
// recording's tracks must thin under their points budget rather than grow without bound.
assert!(run.peak_airborne > 1000, "the extreme load never materialised: {}", run.peak_airborne);
assert!(run.sim.kills > 100, "the defence stopped intercepting: {}", run.sim.kills);
let rec = run.sim.recording().or_else(|| run.sim.replays.last()).expect("the raid was recorded");
let (tracks, journal, poses, misc) = rec.memory_parts();
let points: usize = rec.tracks.iter().map(|t| t.points_len()).sum();
let max_step = rec.tracks.iter().map(|t| t.step()).max().unwrap_or(0);
eprintln!("extreme recording: len {} ticks, tracks {:.2} MiB ({points} points, max step {max_step}), journal {:.2} MiB, poses {:.2} MiB, misc {:.2} MiB", rec.len, tracks as f64 / (1024.0 * 1024.0), journal as f64 / (1024.0 * 1024.0), poses as f64 / (1024.0 * 1024.0), misc as f64 / (1024.0 * 1024.0));
assert!(max_step > airdef::sim::record::STEP, "the points budget never thinned the tracks");
let peak = run.peak_total + m.rehash_headroom();
assert!(peak < PEAK_BUDGET, "extreme peak {} MiB over the {} MiB budget:\n{}", peak >> 20, PEAK_BUDGET >> 20, m.text());
}
+1 -1
View File
@@ -714,7 +714,7 @@ def test_wasm():
BUDGET_SCENARIO = "tests/budgets/wasm_flat_budget.toml"
BUDGET_ASSERTED_SHA256 = "505c8cea05771989f835d2315442862bd6df1ec39a51c2ad2f496246d1367fe3"
BUDGET_ASSERTED_SHA256 = "5313a882621cd833ecd5945c0d46b88cdce47388db210beb8dc9a4912efa3329"
def fuel_measurements(output):