Skip to content

heliopause: skip digest and fsync on disposable export spans - #587

Draft
FujitsuPolycom wants to merge 1 commit into
NVIDIA:mainfrom
FujitsuPolycom:perf/heliopause-skip-disposable-span-fsync
Draft

FujitsuPolycom wants to merge 1 commit into
NVIDIA:mainfrom
FujitsuPolycom:perf/heliopause-skip-disposable-span-fsync

Conversation

@FujitsuPolycom

@FujitsuPolycom FujitsuPolycom commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Why

During rank executable assembly, materialize_span extracted disposable uncompressed graph and cubin spans into publish_payload's private temporary directory through the durable payload helper (materialize), computing a standalone SHA-256 digest that was immediately discarded and issuing a per-span fsync before rank archive sealing re-read, compressed, hashed, and synced the archive.

What changed

  • heliopause/src/export/core.rs & docs/runtime-core-design.md:
    • Before: materialize_span delegated to materialize, hashing each temporary uncompressed cubin or graph span and calling sync_all() on the temporary file before archive compression.
    • After: materialize_span copies source pieces through a bounded 4 MiB BufWriter (4 KiB..=4 MiB), flushes buffered writes via into_inner(), and unlinks the temporary file on read, write, or flush error. Rank executable sealing (compress_stream + sync_all() on .sealing-{rank} + install_path_bytes) and final core publication retain full chunk-digest authentication and fsync durability. Split out from heliopause, helios: parallelize Engram plane assembly in core export #586.
  • Compatibility: Existing signed runtime cores, container layouts, and Protobuf schemas remain unchanged.

Claimed benefit and result

  • Expected effect: Rank assembly avoids redundant SHA-256 passes and per-span fsync barriers on disposable cubin and graph staging files while preserving exact span bytes, error cleanup, and final archive durability.
  • Draft status: Remains in Draft pending live GPU export timing verification.

Supporting evidence and limitations

Tested at candidate commit 38876f608aab29a38149867782d34a9f0ee4635f on main (ba3afb13a7e9836080c23eadf8e1c17ee96e6e7a) in non-root Linux (uid=1000):

Discord: Dooner

@voipmonitor voipmonitor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Draft Review & Test Report (commit bcd28e8d)

Verdict: Approve once out of draft (minor items & rebase coordination with #586) — durability and integrity are sound.

Automated Test Results

  • cargo test --locked --release --manifest-path heliopause/Cargo.toml --lib (default parallel threads) — 209 passed, 0 failed.

Integrity & Durability Check

  • Verified that materialize_span is private to heliopause/src/export/core.rs with exactly two non-test callers (cubins at core.rs:1862 and graphs at core.rs:1913), both writing solely into publish_payload's private .flare-payload-* TempDir for PublishResource.
  • helios/src/core/export.rs always re-reads PublishResource.path through compress_stream (hashing every plaintext chunk into signed chunk_sha256, zstd-compressing, calling sync_all() on .sealing-{rank}, and verifying + syncing via install_path_bytes), then deletes the entire TempDir on return or error.
  • BufWriter closes before fs::remove_file(&path) on read/write/flush errors (Windows-safe).

Minor Items Before Ready/Merge

  1. [Merge coordination] Directly conflicts with #586 in docs/runtime-core-design.md:323, heliopause/src/export/core.rs:2077 (materialize_span), and the test insertion point in mod packing_metadata_tests. Please rebase cleanly with #586 so #587's no-digest/no-fsync materialize_span wins while #586's cleanup removing fn materialize stays intact.
  2. [Minor] Replace the internal fork PR reference Split out from #30 in the PR description with #586.
  3. [Nit] Hoist use std::io::{Read, Seek, Write}; out of the for piece loop (core.rs:2092) and consider placing the new test in mod payload_export_tests.

Why:
During rank executable assembly, `materialize_span` extracted disposable
uncompressed graph and cubin spans through the durable payload materializer,
computing a standalone SHA-256 digest and calling `fsync` on temporary files
whose digest was immediately discarded before archive sealing.

What:
Before: `materialize_span` called `materialize`, hashing every temporary span
and syncing its temporary file to disk before rank archive sealing.
After: `materialize_span` copies span pieces through a bounded 4 MiB
`BufWriter`, flushes buffered bytes via `into_inner()`, removes the temporary
file if reading or flushing fails, and leaves compression, hashing, and
`fsync` to rank archive and final core publication. Existing signed runtime
cores and wire schemas remain unchanged.

Result:
Temporary cubin and graph extraction avoids redundant SHA-256 passes and
per-span `fsync` barriers while keeping final executable and core durability
syncs intact. Live GPU export throughput has not yet been measured on this
revision.

Evidence:
- `cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --lib core::`: 484 passed, 11 ignored, 0 failed.
- `cargo test --locked --release --manifest-path heliopause/Cargo.toml --lib`: 209 passed, 5 ignored, 0 failed.
- `pytest -q -rs tests/preparation/test_core_boundary.py tests/test_design_review_hook.py`: 22 passed.
- End-to-end GPU export timing and Windows native export remain unverified on this revision.

Discord: Dooner

Design-Signed-Off-By: Antigravity (Gemini 4); design-review=c3a9
Signed-off-by: FujitsuPolycom <[email protected]>
@FujitsuPolycom

Copy link
Copy Markdown
Contributor Author

@voipmonitor Addressed at 38876f608aab29a38149867782d34a9f0ee4635f (rebased onto main ba3afb13). The PR description has also been updated.

  1. Merge and rebase coordination with #586:

  2. Replace internal fork PR reference with #586:

    • Fix: Replaced Split out from #30 with Split out from #586 in the PR description.
    • Remaining limit: None.
  3. Hoist std::io imports out of the piece loop and move test to mod payload_export_tests (heliopause/src/export/core.rs:2081):

    • Fix: Hoisted use std::io::{Read, Seek}; to the top of fn materialize_span (BufWriter and Write are already imported at module scope) and moved disposable_span_materialization_preserves_bytes_and_cleans_up_failed_flushes from mod packing_metadata_tests into mod payload_export_tests.
    • Verification (38876f60): cargo test --locked --release --manifest-path heliopause/Cargo.toml --lib -> 209 passed, 5 ignored, 0 failed (0 warnings).
    • Remaining limit: GPU export timing and Windows native export remain unverified on this revision.

Could you take another look at 38876f60?

@flare-autobot flare-autobot added the performance Performance, latency, throughput, or memory-efficiency investigation or improvement. label Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Performance, latency, throughput, or memory-efficiency investigation or improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants