Skip to content

Buffered origin pull-through loads the whole blob into memory before serving #1132

Closed

Description

@alpergundogdu

Summary

The buffered origin pull-through (cache.populate → engine.pull_through → origin.fetch) reads the entire blob from the origin into memory (and imports it into the store) before any byte is served. For large blobs this spikes RAM proportional to blob size — observed serving a 708 MB blob (~700 MB transient).

Detail

The window-paced pull-through (#856) bounds per-request exposure to pull_ahead_bytes for offset-0 paid requests, but the buffered fallback path still buffers the whole blob. Any request that routes to the buffered path (resumed request, non-offset-0, or when the window provider is unattached) loads the full blob.

Fix

Stream the origin read → BLAKE3-verify → serve/store incrementally, bounding memory to a fixed window regardless of which pull-through path is taken. (For fs origins the zero-copy pass-through issue streams directly from the file; this issue covers the http/s3 buffered path.)

Related

  • Efficient-origin-serving issue (zero-copy pass-through / prewarm).

Activity

  1. altanoruc commented on Jul 19, 2026

    @altanoruc
    Contributor

    Automated triage note for a later run: current main has changed materially since this was filed. CacheEngine::pull_through_attempt now streams origin bodies larger than origin_retry.buffered_max_bytes into the store via import_and_verify_stream; only small bodies take drain_to_bytes. CacheEngine::get still waits for commit and then read_local before returning to the serve path.

    Please clarify whether the remaining goal is (1) bounded memory only, in which case the large-blob premise may already be fixed and this issue should be re-verified/closed, or (2) serving bytes to the client before the raw HTTP/S3 origin body has completed whole-root BLAKE3 verification. The latter needs an explicit authenticity design (for example a proof/outboard source); a raw stream cannot be authenticated against its final BLAKE3 root incrementally without such proof. That choice is security-relevant and should be pinned before dispatch.

  2. added this to the v0.1 milestone on Jul 28, 2026
  3. assigned and unassigned on Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions