Skip to content

cli: the throwaway (0,0) prelude open claims a fill on the node and abandons it #2063

Closed

Description

@yigitdot

Summary

open_fetch_prelude (crates/cli/src/commands/fetch.rs:1944-1980) opens every entry twice: a throwaway (byte_offset=0, byte_len=0) open_progressive_pull whose only purpose is to read the signed StreamResponse.total_bytes (the ranged store is keyed on (root, total_bytes)), then drop(first_pull) — which closes the connection — and then drive opens the real (0, total_bytes) leg.

Once every miss routes through the two-leg spine (#2060 option B), that throwaway open is a full serve-miss on the node: serve_via_backend_origin / serve_via_window_pull_through sign the response, claim_fill, and spawn a pull leg that draws its first PULL_WINDOW_FLOOR (1 MiB + 48 KiB) from origin before the node notices the client is gone (the serve leg only learns of the close on its first write, after frame 1 lands).

Cost per entry

  • One {H}.obao4 GET for the dispatch serviceability probe (plus the size HEAD), then the same probe again on the real open.
  • Up to one PULL_WINDOW_FLOOR origin draw that nobody pays for. In the ordering where the throwaway's teardown lands before the real open's claim_fill, that draw is cancelled mid-flight and the real open's fresh owner re-draws the same span — a duplicate origin GET.
  • In the other ordering the real open attaches to the live fill and nothing is wasted. The bundle pull: cold-miss whole-blob request hits the buffered range tier; CLI 30s stall clock fires on multi-GB files #2060 PR pins both orderings (throwaway_open_then_real_open_coalesces_onto_the_live_fill, throwaway_open_torn_down_before_real_open_still_serves in crates/node/tests/origin_range_pull.rs); the torn-down variant asserts ranged_gets <= 2 because of this duplicate.

On the node→node path the same shape costs a real upstream open + header handshake per entry.

Proposed fix (CLI side)

Do not claim on the prelude. Options:

  1. Reuse the first open as the real leg: open (0, 0) once, keep the UpstreamPull, create the ranged store from its header, and hand the live pull to drive as the first leg instead of re-opening. The driver already has the resume/gap machinery; the prelude just needs to become leg 1.
  2. Learn total_bytes without a stream claim: a cdn/probe/v1 response already carries the blob size for a holder; for a miss-serving node it does not, so this only removes the prelude on hits.

Option 1 is the real fix. Filed from the #2060 plan (Task 6 note); not in that PR because it changes the CLI's fetch structure rather than the node's routing.

🤖 Generated with Claude Code

Activity

  1. added
    kind:feature
    area:cli
    area:node
    on Sep 19, 2026
  2. yigitdot commented on Sep 19, 2026

    @yigitdot
    ContributorAuthor

    Measured while pinning this sequence in crates/node/tests/origin_range_pull.rs (#2060 PR, tests throwaway_open_then_real_open_shares_one_multi_draw_fill / throwaway_open_torn_down_before_real_open_still_serves):

    The real (0, total) open does not reach claim_fill while the throwaway's draw is in flight. It parks earlier, in serve_audit → iroh-blobs status(hash), which serialises behind the same hash's in-flight import_bao. With a 3 s origin delay on the throwaway's first draw, the real open's signed StreamResponse arrived after 3.08 s and no second origin probe ran — the 200 KiB blob was already complete, so the real open was served as a cache hit.

    Consequence for every cold CLI entry today: time-to-first-byte on the real open is delayed by the throwaway's first draw (one PULL_WINDOW_FLOOR ≈ 1 MiB from origin) before the real open even probes. On a multi-draw blob the real open then attaches or owns a fresh session (both pinned); no span is fetched twice in full. Option 1 here (reuse the first open as the real leg) removes the delay and the wasted draw together.

    🤖 Generated with Claude Code

  3. self-assigned this
    on Sep 22, 2026
  4. moved this from Backlog to In progress in deCDNon Sep 22, 2026
  5. moved this from In progress to Done in deCDNon Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:cliarea:nodekind:feature

Type

No type

Fields

Priority

None yet

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions