sim: account where the mod's memory goes (Sim::memory, per-cache bytes)
The fullscreen-map OOM (Ground::answer rehash under a large raid) needs a measured breakdown, not a guess: Sim::memory estimates each consumer's allocated capacity (hashbrown tables with their control bytes, vec capacities, BTreeMap nodes) — Ground.known, WorldCache.secs and rays, the sim vectors and radar tracks, the recording and kept replays, Intel/recon, routes, sites, strikes, the raid plan. MemoryReport::rehash_headroom names the transient a rehash adds (old + new table of the biggest map). Ground::known_len exposes the column count the budget tests guard. Co-Authored-By: Kimi Code <noreply@moonshot.ai>
This commit is contained in:
@@ -127,6 +127,23 @@ pub(super) struct Plan {
|
||||
mapped: bool,
|
||||
}
|
||||
|
||||
impl Plan {
|
||||
/// What the plan holds, about: the grid's heights, prices, routes and items (see `sim::memory`).
|
||||
pub(super) fn bytes(&self) -> usize {
|
||||
use super::memory::{map_bytes, vec_bytes};
|
||||
map_bytes(self.prices.len(), std::mem::size_of::<DroneKind>() + std::mem::size_of::<Vec<f32>>())
|
||||
+ self.prices.values().map(|p| vec_bytes(p)).sum::<usize>()
|
||||
+ map_bytes(self.routes.len(), std::mem::size_of::<(DroneKind, i32, i32, i32)>() + std::mem::size_of::<Vec<DVec3>>())
|
||||
+ self.routes.values().map(|r| vec_bytes(r)).sum::<usize>()
|
||||
+ vec_bytes(&self.items)
|
||||
+ vec_bytes(&self.done)
|
||||
+ vec_bytes(&self.wants)
|
||||
+ vec_bytes(&self.heights)
|
||||
+ vec_bytes(&self.unanswered)
|
||||
+ self.knowledge.bytes()
|
||||
}
|
||||
}
|
||||
|
||||
/// The raid in progress: the counts at its start, for the report.
|
||||
pub(super) struct WaveStats {
|
||||
kills: u32,
|
||||
|
||||
Reference in New Issue
Block a user