pub fn read_cache<const FULL_ROUNDS: usize, G, Srs>(
identifier: &str,
path: &Path,
srs: Arc<Srs>,
) -> Result<MmapProverIndex<FULL_ROUNDS, G, Srs>, CacheError>where
G: KimchiCurve<FULL_ROUNDS>,
Srs: SRS<G>,
G::BaseField: PrimeField,Expand description
Reads a cache file produced by write_cache and returns an
MmapProverIndex: a ProverIndex-compatible wrapper whose bulk
Vec<F> fields are backed by the mmap’d file rather than heap copies.
Reading is a single mmap(2) syscall; the prover reads field elements
directly from page-cache pages which the kernel can evict under
memory pressure and re-fault on demand. This is the “OS can evict
cached keys” behaviour the cache was designed for.
The returned MmapProverIndex [Deref]s to &ProverIndex, so existing
callers that pass &ProverIndex<...> into the prover continue to work
unchanged.
§Safety of the construction
This function constructs Vec<F> values via
Vec::from_raw_parts(mmap_ptr, len, len), pointing directly into the
mmap. Those Vecs are bound by the lifetime of the mmap — which
MmapProverIndex guarantees by holding an Arc<ReadOnlyMmap>
alongside the wrapped index, and by wrapping the inner ProverIndex
in ManuallyDrop so Vec::drop can never run on them. See the
docstring on MmapProverIndex for the full invariant.
Identifier and ark-ff version must match the values the file was produced with, otherwise a descriptive error is returned.