diff --git a/crates/ml/examples/precompute_features.rs b/crates/ml/examples/precompute_features.rs index c61961e2a..1a6f70291 100644 --- a/crates/ml/examples/precompute_features.rs +++ b/crates/ml/examples/precompute_features.rs @@ -671,8 +671,17 @@ async fn main() -> Result<()> { // f64 volume for size-weighted features. alpha_snapshots = all_snapshots; if let Some(t) = all_trades { + // CONSUME the original DbnTrade Vec while building the + // Mbp10Trade Vec. Using `.iter()` here previously kept + // the original ~10GB Vec alive for the duration of the + // transformation, so peak memory transiently doubled + // to ~25GB (DbnTrade + Mbp10Trade Vecs simultaneously) + // and OOM-killed the 9-quarter precompute at 56Gi + // (2026-05-16). `.into_iter()` drops the source + // allocation element-by-element as the destination + // builds, capping peak at the larger of the two. alpha_trades = t - .iter() + .into_iter() .map(|dbn| ml::features::Mbp10Trade { price: dbn.price, volume: dbn.volume as f64,