Build a Lean `Array (G × Array G) × Array ((G × Array G) × IOKeyInfo)` from an `IOBuffer`. The first array enumerates per-channel data arenas; the second is the channel-keyed info map.
(io_buffer: &IOBuffer)
| 681 | /// pure ratio calibrated on large shards under-reserves small ones |
| 682 | /// (measured: 151 ISLB shards at 1.1-4.8 GiB estimated ran to 175 GB |
| 683 | /// actual against a 110 GiB budget — an OOM on a real 128 GB box). |
| 684 | /// Fit on the two ISLB partitions (2026-08-22, measured in-flight |
| 685 | /// RSS): 5.7 MB owned -> ~9.6 GB and 1.4 MB -> ~5.5 GB, giving |
| 686 | /// ~4 GiB + ~1000x; both terms rounded up for cross-shard spread. |
| 687 | const EXEC_RSS_FIXED_BYTES: usize = 9 * (1 << 29); // 4.5 GiB |
| 688 | // Two calibrations, each accurate in its own regime, combined as a MAX |
| 689 | // in `exec_rss_estimate` because the per-owned-byte execution footprint |
| 690 | // is env-dependent and the gate's contract is NEVER OOM: |
| 691 | // - The affine fit (4.5 GiB + 1100x) measured on ISLB's small shards |
| 692 | // (1.4-5.7 MB owned; a pure ratio under-reserved them and OOM'd a |
| 693 | // 128 GB box). |
| 694 | // - The pure ratio (2500x, ~2300x measured + margin) validated on |
| 695 | // Mathlib's full-width 233-shard batch at +2% of estimate; the |
| 696 | // affine slope alone under-reserved Mathlib-class shards and |
| 697 | // over-admitted a 132-shard full-width batch to 486/495 GB |
| 698 | // (OOM, 2026-08-29 — the first Mathlib full-width run under the |
| 699 | // affine constant). |
| 700 | // The max reproduces each fit where it was measured: small shards take |
| 701 | // the affine branch (ISLB bench reservations unchanged), large shards |
| 702 | // the ratio branch. |
| 703 | const EXEC_RSS_PER_OWNED_BYTE: usize = 1100; |
| 704 | const EXEC_RSS_RATIO_PER_OWNED_BYTE: usize = 2500; |
| 705 | |
| 706 | /// Per-shard execution-RSS reserve: the max of the two measured fits |
| 707 | /// (see the constants above). |
| 708 | fn exec_rss_estimate(owned_bytes: usize) -> usize { |
| 709 | EXEC_RSS_FIXED_BYTES |
| 710 | .saturating_add(owned_bytes.saturating_mul(EXEC_RSS_PER_OWNED_BYTE)) |
| 711 | .max(owned_bytes.saturating_mul(EXEC_RSS_RATIO_PER_OWNED_BYTE)) |
| 712 | } |
| 713 | |
| 714 | /// FFI: the detected prover/execution RAM budget in bytes |
no test coverage detected