Skip to content

feat(prover): disk-spill mmap backend for large program proving#444

Closed
ColoCarletti wants to merge 5 commits into
mainfrom
feat/disk-spill-v2
Closed

feat(prover): disk-spill mmap backend for large program proving#444
ColoCarletti wants to merge 5 commits into
mainfrom
feat/disk-spill-v2

Conversation

@ColoCarletti
Copy link
Copy Markdown
Collaborator

Summary

Adds mmap-based disk spilling for trace tables, LDE columns, and Merkle tree nodes, enabling proving of large programs
(64M+ instructions) that would otherwise OOM.

Changes

Crypto layer — mmap backing for core data structures:

  • Table<F>: spill_to_disk() moves trace data from heap to mmap'd tempfile, get() reads transparently from either
    source
  • LDETraceTable: spill_main_from_pool() and add_aux_from_pool() persist LDE columns to disk before pool buffers are
    reused
  • MerkleTree: spill_nodes_to_disk() moves tree nodes to mmap, accessed via node_get()
  • FieldElement<F>: added #[repr(transparent)] for safe mmap pointer cast
  • Fingerprint optimization: avoid redundant ×1/×(-1) multiplications in LogUp

Prover pipeline — chunked processing with disk spill:

  • Phase A (main commit): spill main trace → extract to pool → LDE → spill LDE + Merkle tree → reuse pool for next chunk
  • Phase C (aux commit): build + commit K aux traces at a time, spill each, free heap
  • Phase D (deep composition): read LDE directly from spilled mmap — no recomputation

Trace builder — memory-bounded bitwise processing:

  • chunk_generate_and_spill: generates each trace chunk and immediately spills to disk
  • Incremental bitwise: flush_bitwise! macro updates multiplicities in 1M-row batches instead of accumulating all
    bitwise ops (saves ~14 GB at 64M instructions)
  • Early drops: memw_ops, lt_ops, cpu_ops freed as soon as their traces are generated

CLI:

  • prove and verify commands with --max-rows flag for per-table chunk size control
  • Disk-spill status indicator

All changes are behind the disk-spill feature flag (default for CLI). Without the flag, behavior is identical to main.

Test Results

Program Instructions Prove + Verify
sub 6
fib_iterative_2M 2M
fib_iterative_32M 32M ✅ (server)
fib_iterative_64M 64M ✅ (server, 128GB RAM)
fib_iterative_128M 128M OOM (raw ops exceed 128GB before disk-spill kicks in)

@ColoCarletti
Copy link
Copy Markdown
Collaborator Author

/bench

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 18, 2026

Benchmark — fib_iterative_8M (median of 3)

Table parallelism: 32 (auto = cores / 3)

Metric main PR Δ
Peak heap 256381 MB 230543 MB -25838 MB (-10.1%) 🟢
Prove time 99.470s 293.881s +194.411s (+195.4%) 🔴

⚠️ Regression detected — heap or time increased by more than 5%.

✅ Low variance (time: 2.5%, heap: 1.1%)

Commit: 71c1377 · Baseline: built from main · Runner: self-hosted bench

@ColoCarletti
Copy link
Copy Markdown
Collaborator Author

/bench

1 similar comment
@ColoCarletti
Copy link
Copy Markdown
Collaborator Author

/bench

@ColoCarletti
Copy link
Copy Markdown
Collaborator Author

/bench

1 similar comment
@ColoCarletti
Copy link
Copy Markdown
Collaborator Author

/bench

@gabrielbosio
Copy link
Copy Markdown
Collaborator

/bench

1 similar comment
@gabrielbosio
Copy link
Copy Markdown
Collaborator

/bench

@gabrielbosio
Copy link
Copy Markdown
Collaborator

/bench

# Conflicts:
#	Cargo.lock
#	crypto/stark/src/table.rs
#	prover/src/tables/trace_builder.rs
@gabrielbosio
Copy link
Copy Markdown
Collaborator

superseded by #466

@gabrielbosio gabrielbosio deleted the feat/disk-spill-v2 branch April 20, 2026 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants