Expand description
Streaming compression / decompression helpers。
s4_codec::Codec の bytes-in / bytes-out API は memory cap (5 GiB) を持つため
大規模オブジェクトで OOM 危険。本 module は async-compression 経由で zstd を
AsyncRead/AsyncWrite に差し込み、StreamingBlob (= futures::Stream<Bytes>)
↔ AsyncRead を tokio_util::io で橋渡しする。
§対応 codec
- CpuZstd:
async_compression::tokio::bufread::ZstdDecoderで完全 streaming - Passthrough: 入力 stream をそのまま返す (ゼロコスト streaming)
- NvcompZstd / NvcompBitcomp: nvCOMP は batch API のため per-chunk batch 処理 (Phase 2.1 で追加予定、現状は default の bytes-based に fallback)
§整合性検証
Streaming GET では bytes 全体の CRC32C をオンザフライで計算しつつ stream を
流す Crc32cVerifier adapter を被せる。最後の chunk が yield された時点で
manifest.crc32c と比較し、不一致なら error として伝播 (= client 側で
body parse 失敗として現れる)。
Constants§
- DEFAULT_
S4F2_ CHUNK_ SIZE streaming_compress_to_framesの default chunk size。- DEFAULT_
S4F2_ INFLIGHT streaming_compress_to_framesの default in-flight depth (v0.3 #12)。
Functions§
- async_
read_ to_ blob AsyncReadを 1 chunk = 64 KiB のStreamingBlobに変換 (size 不明の chunked stream)。- blob_
to_ async_ read StreamingBlobを AsyncRead として扱えるラッパ。- cpu_
zstd_ decompress_ stream - CpuZstd で
bodyを streaming に decompress したStreamingBlobを返す。 - pick_
chunk_ size - v0.4 #16: pick a chunk size for
streaming_compress_to_framesbased on the request’sContent-Length(when known). Smaller objects get smaller chunks (avoids carrying multi-MiB framing infrastructure on a 64 KiB upload); large objects get larger chunks (amortises GPU launch overhead and keeps the sidecar small). - streaming_
compress_ cpu_ zstd bodyを CPU zstd で input-streaming 圧縮し、(compressed bytes, manifest) を返す。memory peak は zstd window + 64 KiB read buffer + 圧縮済 output ≈compressed_size + ~100 MB。入力 5 GB を 100 MB に圧縮するケースで peak は ~200 MB (vs. naive bytes-buffered だと peak 5 GB)。- streaming_
compress_ to_ frames - 入力
bodyを chunked + framed + pipelined に圧縮した output を返す (v0.2 #4 + v0.3 #12)。 - streaming_
compress_ to_ frames_ with - Like
streaming_compress_to_framesbut lets callers tune the in-flight depth — useful in the bench harness, and as the building block anystreaming_compress_to_framescallers extend if their workload needs a non-default pipelining depth. - streaming_
passthrough bodyを passthrough で集めるだけ。CRC32C も計算する。- supports_
streaming_ compress - supports_
streaming_ decompress - codec が streaming-aware かを判定 (S4Service 側で fast path 分岐に使う)。