( arr: &LeanArray<LeanBorrowed<'_>>, )
| 734 | } |
| 735 | |
| 736 | /// `MemAvailable` from `/proc/meminfo`, in bytes (Linux; includes |
| 737 | /// reclaimable page cache). `None` if unreadable — the caller then |
| 738 | /// disables the gate rather than guessing. |
| 739 | fn available_ram_bytes() -> Option<usize> { |
| 740 | let s = std::fs::read_to_string("/proc/meminfo").ok()?; |
| 741 | let rest = s.lines().find_map(|l| l.strip_prefix("MemAvailable:"))?; |
| 742 | let kib: usize = rest.trim().trim_end_matches("kB").trim().parse().ok()?; |
| 743 | Some(kib * 1024) |
| 744 | } |
| 745 | |
| 746 | // cast_precision_loss: the [ram-gate] line renders byte counts in GiB |
| 747 | // for humans; f64's 52-bit mantissa is exact far past any real budget. |
| 748 | #[allow(clippy::cast_precision_loss)] |
| 749 | #[unsafe(no_mangle)] |
| 750 | extern "C" fn rs_aiur_toplevel_shard_check_batch( |
no test coverage detected