More
This commit is contained in:
parent
cd34ee693f
commit
05a1f316e1
58 changed files with 3113 additions and 1277 deletions
|
|
@ -37,6 +37,38 @@ use tracing_subscriber::EnvFilter;
|
|||
|
||||
use state::{AppState, SharedState};
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn resident_memory_kib() -> Option<u64> {
|
||||
let status = std::fs::read_to_string("/proc/self/status").ok()?;
|
||||
status.lines().find_map(|line| {
|
||||
line.strip_prefix("VmRSS:")?
|
||||
.split_whitespace()
|
||||
.next()?
|
||||
.parse()
|
||||
.ok()
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn trim_allocator(label: &'static str) {
|
||||
let before = resident_memory_kib();
|
||||
let trimmed = unsafe { libc::malloc_trim(0) };
|
||||
let after = resident_memory_kib();
|
||||
if let (Some(before), Some(after)) = (before, after) {
|
||||
info!(
|
||||
label,
|
||||
trimmed = trimmed != 0,
|
||||
rss_before_mib = format_args!("{:.1}", before as f64 / 1024.0),
|
||||
rss_after_mib = format_args!("{:.1}", after as f64 / 1024.0),
|
||||
released_mib = format_args!("{:.1}", before.saturating_sub(after) as f64 / 1024.0),
|
||||
"Allocator trim"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
fn trim_allocator(_label: &'static str) {}
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(
|
||||
name = "perfect-postcode",
|
||||
|
|
@ -166,6 +198,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
cli.postcode_features.display(),
|
||||
);
|
||||
let property_data = data::PropertyData::load(&cli.properties, &cli.postcode_features)?;
|
||||
trim_allocator("property data load");
|
||||
info!(
|
||||
rows = property_data.lat.len(),
|
||||
features = property_data.num_features,
|
||||
|
|
@ -194,6 +227,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
|
||||
info!("Loading POI data from {}", poi_path.display());
|
||||
let poi_data = data::POIData::load(&poi_path)?;
|
||||
trim_allocator("poi data load");
|
||||
info!(pois = poi_data.lat.len(), "POI data loaded");
|
||||
|
||||
info!("Building POI spatial grid index");
|
||||
|
|
@ -206,6 +240,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
}
|
||||
info!("Loading place data from {}", places_path.display());
|
||||
let place_data = data::PlaceData::load(places_path)?;
|
||||
trim_allocator("place data load");
|
||||
info!(places = place_data.name.len(), "Place data loaded");
|
||||
|
||||
// Load postcode boundaries
|
||||
|
|
@ -221,6 +256,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
postcodes_path.display()
|
||||
);
|
||||
let postcode_data = data::PostcodeData::load(postcodes_path)?;
|
||||
trim_allocator("postcode boundary load");
|
||||
info!(
|
||||
postcodes = postcode_data.postcodes.len(),
|
||||
"Postcode boundaries loaded"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue