You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf(blockstore,bucket): stream body blobs instead of buffering whole in RAM
Addresses PR review (alanshaw): the spool buffered each object-body blob
(up to max_blob_size = 256 MiB) whole in memory on both the write and read
paths, so peak RAM was blob_size × concurrency — wrong for a memory-bound
appliance, and counter to the architecture's "nothing held whole in RAM"
(§5/§7.1). Body blobs now stream; the small-catalog-block path (GetBlock /
PutBlock, CID-keyed, fine in RAM) is unchanged.
New BlobWriter/BlobReader seams (WriteBlob / OpenBlob); ReadStore gains
BlobReader.
Write: SplitBody streams each blob through Spool.WriteBlob, which hashes
(sha256) while copying straight to a temp file (atomic rename to the digest
path) — the blob never sits whole in RAM. Replaces the bytes.Buffer +
PutBlock(block.Block) per blob.
Read: blobBodyReader streams via OpenBlob(digest) (io.ReadCloser) instead
of GetBlock → os.ReadFile, holding at most one open blob at a time and
seeking into it for a ranged read, so peak RAM per concurrent GET is a copy
buffer, not a 256 MiB blob. OpenBlob is implemented by Spool (os.Open),
Forge (stream the /content/retrieve body, dropping io.ReadAll — GetBlock
and OpenBlob now share a `retrieve` helper), and Layered/Cached
(spool → base, no LRU for streamed blobs).
Validated in-process: full suite + new bucket/chunker tests (multi-blob
round trip, mid-blob/boundary-spanning ranged reads, empty body) and
blockstore OpenBlob tier-dispatch tests. The real-network Forge.OpenBlob
path is covered by smelt's read-after-eviction e2e, which currently can't
run — the published piri:main image fails to boot (fx: NewPieceAccepter
missing ucan.Issuer), unrelated to this change — so that leg is pending a
working piri image.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments