Repository navigation
fix(flare-cli,helios): release page cache with O_DIRECT peer serving, inherit orbit memory reserve, and log integrated MemInfo - #713
Conversation
… inherit orbit memory reserve, and log integrated MemInfo Why - On Linux unified-memory GPUs (such as GB10), CUDA allocations and context creation can respond to Linux `MemFree` rather than `MemAvailable` when tens of gigabytes of clean page cache accumulate from core distribution and buffered cache I/O (NVIDIA#630). - `flare-cli`'s peer-serving path (`distribution::serve_source`) streamed core shards via buffered `RangeReader` before dropping page cache, leaving multi-GiB bursts in the page cache during transfer, and four buffered I/O sites across `flare-cli` and `helios` omitted `release_page_cache`. - `flare orbit run` did not inherit `[memory] reserve` from host configuration (`config.rs`), unlike `flare run`, while persistent groups still needed their stored `--memory-limit` preserved unless overridden on the command line. - When integrated-GPU cache planning was memory-limited or `cuDevicePrimaryCtxRetain` / `cuCtxCreate_v2` returned `CUDA_ERROR_OUT_OF_MEMORY`, diagnostics did not surface Linux `MemFree / MemAvailable / Cached` or hint when reclaimable page cache was likely blocking allocation. What changed - Direct peer serving and missed `release_page_cache` sites: - Re-exported `eos` direct-I/O helpers (`FileReadAt`, `allocate_aligned`, `direct_reopen`, `free_aligned`) from `helios/src/lib.rs`. - Updated `flare-cli/src/distribution.rs::serve_source` to reopen files with `direct_reopen` on Unix and stream 4 MiB aligned chunks from a zero-initialized `AlignedBuffer` (handling arbitrary unaligned offsets, multi-range requests, and unaligned EOF byte-for-byte identically to `cache::RangeReader`), always calling `release_page_cache_range` for every served range afterward (including on error) to evict any pre-existing or tmpfs cached pages, and falling back cleanly to buffered `RangeReader` + `release_page_cache_range` when `O_DIRECT` is unsupported or returns `EINVAL`. - Added `release_page_cache` / `release_page_cache_range` at the four missed buffered I/O sites: `flare-cli/src/orbit/controller.rs`, `flare-cli/src/core_cache.rs`, `flare-cli/src/orbit/agent.rs::get`, and `helios/src/core/cache.rs` (`write_stream`, `verify_file`, `hash_file`, and non-Windows `copy_file`). - Orbit `[memory] reserve` propagation: - Inherited `self.memory.reserve` into `OrbitCommand::Run` in `flare-cli/src/config.rs` only when `--memory-limit` is unset. - Tracked config-inherited `--memory-limit` in `flare-cli/src/main.rs` and `flare-cli/src/orbit/controller.rs::merge_serving_options` so restarting a persistent group preserves its saved `--memory-limit` while explicit CLI `--memory-limit` still overrides it. - Linux integrated-GPU `/proc/meminfo` diagnostics: - Added `LinuxMemInfo { free, available, cached }` parser and `CUDA_ERROR_OUT_OF_MEMORY` constant in `helios/src/runtime_core/`. - Appended `MemFree / MemAvailable / Cached` to the `Plan cache` summary on Linux integrated GPUs and emitted a warning when `MemAvailable - MemFree > 10 GiB` and KV sizing is limited by memory. - Enriched `cuDevicePrimaryCtxRetain` and `cuCtxCreate_v2` `CUDA_ERROR_OUT_OF_MEMORY` failures on Linux integrated GPUs with `MemFree / MemAvailable / Cached` (and a `drop_caches` hint when `MemAvailable - MemFree > 4 GiB`) while preserving the structured `ExecutionError::Driver(CudaError { code: 2, .. })` error. Verification - CPU-only verification on Linux x86_64 (no live GB10 run yet): - Verified `.githooks/commit-msg` passes on the staged diff and message. - `cargo test --locked --release --manifest-path flare-cli/Cargo.toml`: 251 passed (225 bin + 9 cache_commands + 6 cli + 4 inspect + 7 unverified_payload), 0 failed, 3 ignored. - `cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server`: 1948 passed (1886 lib + 62 integration), 0 failed, 86 ignored. - `cargo test --locked --release --manifest-path flare/Cargo.toml`: 255 passed (247 lib + 7 packed_canonical_download + 1 reference_workflows), 0 failed, 4 ignored. - `cargo clippy --locked` on `flare-cli --all-targets` and `helios --features runtime-core,server --all-targets`: 0 errors/warnings on touched lines. - `rustfmt --edition 2024 --check`: clean on all touched lines across all 11 files. Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=2e5b Signed-off-by: Joshua Cartu <jcartu@users.noreply.github.com>
|
A case file has been opened for 713. Future reviews will auto-run 90 minutes after code updates are pushed.
|
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: Changes RequestedThe
Walkthrough
Merge Risk: Medium · up to
|
Refs #630
Summary
Release page cache on peer-serving and buffered I/O paths, and serve peers with
O_DIRECT; live GB10 impact remains unmeasured. In addition, propagate[memory] reserveintoflare orbit run(without clobbering saved persistent-group overrides) and surface Linux/proc/meminfodiagnostics on integrated-GPU cache planning and CUDA context-creation OOM failures.Changes
O_DIRECTpeer serving and four missedrelease_page_cachesitesflare_eosdirect-I/O helpers (FileReadAt,allocate_aligned,direct_reopen,free_aligned) fromhelios/src/lib.rs.flare-cli/src/distribution.rs::serve_sourceto reopen files withdirect_reopenon Unix and stream aligned 4 MiB chunks via a zero-initializedAlignedBuffer, matchingcache::RangeReaderbyte-for-byte across unaligned offsets, multi-range requests, and unaligned EOF. Aftercopy_ranges_direct(including on error), every served range is released withrelease_page_cache_rangeto evict any pre-existing page-cache pages or Linux >= 6.6 tmpfs pages. Falls back cleanly to bufferedRangeReader+release_page_cache_rangewhenO_DIRECTis unsupported or returnsEINVAL(including mid-stream).release_page_cache/release_page_cache_rangeat four missed buffered I/O call sites:flare-cli/src/orbit/controller.rs(controller uploadputloop)flare-cli/src/core_cache.rs(AlreadyExistscached blob digest re-verification)flare-cli/src/orbit/agent.rs(get, matchingfetch)helios/src/core/cache.rs(write_streamaftersync_all,verify_file,hash_file, and non-Windowscopy_filefor both synced destination and source)[memory] reservepropagation inflare orbit runflare-cli/src/config.rssoCommand::Orbit(OrbitCommand::Run)inheritsself.memory.reserveasMemoryLimit::Reservewhen--memory-limitis unset, matchingCommand::Run.--memory-limitinflare-cli/src/main.rsand merged options viamerge_serving_optionsinflare-cli/src/orbit/controller.rsso restarting a--persistentgroup preserves its saved--memory-limitwhile explicit CLI--memory-limitstill overrides it.Linux integrated-GPU
/proc/meminfodiagnostics andcuCtxCreateOOM enrichmentCUDA_ERROR_OUT_OF_MEMORY(2) inhelios/src/runtime_core/driver.rsandLinuxMemInfo { free, available, cached }parsing inhelios/src/runtime_core/memory.rs.rank.integrated), appendedMemFree / MemAvailable / Cachedto thePlan cachesummary and emitted a stderr warning when KV sizing is limited by memory andMemAvailable - MemFree > 10 GiB.cuDevicePrimaryCtxRetainandcuCtxCreate_v2CUDA_ERROR_OUT_OF_MEMORYfailures on Linux integrated GPUs (helios/src/runtime_core/mod.rs), attachedMemFree / MemAvailable / CachedtoCudaError.description(plus adrop_cacheshint whenMemAvailable - MemFree > 4 GiB) while preserving the structuredExecutionError::Driver(CudaError { code: 2, .. })error.Verification
--locked --release, Linux x86_64):cargo test --locked --release --manifest-path flare-cli/Cargo.toml: 251 passed (225 bin + 9cache_commands+ 6cli+ 4inspect+ 7unverified_payload), 0 failed, 3 ignored.cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server: 1948 passed (1886 lib + 62 integration), 0 failed, 86 ignored.cargo test --locked --release --manifest-path flare/Cargo.toml: 255 passed (247 lib + 7packed_canonical_download+ 1reference_workflows), 0 failed, 4 ignored.cargo clippy --locked --manifest-path flare-cli/Cargo.toml --all-targets: 0 errors/warnings on touched lines.cargo clippy --locked --manifest-path helios/Cargo.toml --features runtime-core,server --all-targets: 0 errors/warnings on touched lines.rustfmt --edition 2024 --check: clean on all touched lines across all 11 files..githooks/commit-msg: passed (design-review=2e5b).Disclosures / Limitations
O_DIRECTpeer serving drops kernel readahead in exchange for avoiding page-cache accumulation, and trailingrelease_page_cache_rangecalls evict any pre-existing cached pages (or tmpfs pages on Linux >= 6.6).CU_DEVICE_ATTRIBUTE_INTEGRATEDandCUDA_ERROR_OUT_OF_MEMORYduring context creation is unconfirmed on target hardware in this environment.Discord: jcartu