Support spilling

This commit is contained in:
Andras Schmelczer 2026-06-20 11:03:04 +01:00
parent 3dd5cde626
commit 8d0ecdab19
18 changed files with 150 additions and 65 deletions

View file

@ -281,6 +281,14 @@ struct Cli {
#[arg(long)]
dist: Option<PathBuf>,
/// Dev only: spill the large property arrays (feature matrix + address-search
/// index) to anonymous files in this directory and memory-map them read-only,
/// instead of holding them on the heap. Trades a little speed for a much
/// smaller resident set so a low-memory dev box can run the full dataset; the
/// mapped pages are file-backed and reclaimable under pressure. Omit in prod.
#[arg(long, env = "SPILL_DIR")]
spill_dir: Option<PathBuf>,
/// URL of the screenshot service (e.g. http://screenshot:8002)
#[arg(long, env = "SCREENSHOT_URL")]
screenshot_url: String,
@ -465,7 +473,15 @@ async fn main() -> anyhow::Result<()> {
cli.properties.display(),
cli.postcode_features.display(),
);
let property_data = data::PropertyData::load(&cli.properties, &cli.postcode_features)?;
let spill_dir = cli.spill_dir.as_deref();
if let Some(dir) = spill_dir {
info!(
"Spill-to-disk enabled: large property arrays will be memory-mapped from {}",
dir.display()
);
}
let property_data =
data::PropertyData::load(&cli.properties, &cli.postcode_features, spill_dir)?;
trim_allocator("property data load");
info!(
rows = property_data.lat.len(),