Skip to content

Paid delivery is stop-and-wait per voucher: throughput is RTT-bound, not link-bound #1477

Closed

Description

@alpergundogdu

What's happening

Paid delivery is stop-and-wait at every voucher boundary. The provider holds the next chunk until the client's voucher arrives, is verified, is fsynced, and is acked — with zero bytes in flight for the whole round trip.

  • Server blocks on read_voucher at each interval: crates/node/src/handlers/client/delivery.rs:78-94
  • Client mirrors it, blocking on VoucherAck before reading the next chunk: crates/client-pull/src/lib.rs:1604-1620
  • A cache-miss serve stacks two of these in series — window_forward_loop's upstream next_chunk pays with its own stop-and-wait (crates/client-pull/src/lib.rs:2053) inside the outer downstream barrier.

Throughput is therefore latency-bound, not link-bound: 1 MiB / (RTT + service_time).

Measured

  • Fsynced redb voucher commit (Durability::Immediate): 3.18 ms, local SSD. Cloud network storage is typically 5-20 ms. It sits on the critical path.
  • Framing at CHUNK_SIZE = 1024: 3.1 GiB/s; serve-side per-chunk encode 1.3 GiB/s. Chunk size is not the bottleneck — resizing it would not help.

Resulting ceiling at the default 1 MiB interval, regardless of link capacity:

RTT 1 ms 5 ms 20 ms 50 ms 100 ms 200 ms
MiB/s 238 122 43 19 9.7 4.9

Going idle for ≥1 RTT every MiB also prevents QUIC's congestion window from reaching steady state, so real throughput lands below these numbers.

Recommendation

Credit-window pipelining. Keep streaming while delivered − paid ≤ credit_window instead of stalling at one interval; client issues the voucher and keeps receiving rather than blocking on the ack. This is the same bounded-credit shape the node already uses for the upstream leg (pull_ahead_bytes).

Nonce ordering is preserved by serializing issuance in ChannelLedger — the server only requires increasing nonces, never ack-before-next.

Proposed defaults: 8 MiB credit window, 4 MiB voucher interval → ~150 MiB/s at 50 ms RTT.

The interval matters independently: vouchers on a channel are serialized by the per-channel mutex at 3.2 ms each, capping a 1 MiB interval at ~313 MiB/s per channel no matter how large the window. Raising the interval lifts that cap linearly; it does not raise exposure, which is the window.

Risk is one-sided. Client exposure stays at zero — vouchers are cumulative over bytes already received, so the client never pays ahead. Server exposure rises from 1 MiB to the window: unbilled egress already served, strictly cheaper than the 1 MiB of speculative USDC the node already fronts upstream per request (DEFAULT_PULL_AHEAD_BYTES, crates/common/src/config/mod.rs:253).

Needs an ADR 003 / ADR 005 amendment for the cadence semantics. No wire break.

Related, found during the same investigation

The barrier is two-sided — and the client side is separate work (#1484)

The client mirrors this stop-and-wait: after sending a voucher it blocks on VoucherAck before reading the next chunk (crates/client-pull/src/lib.rs:2212, :1604-1620, :2053). Unlike the server, the client's per-voucher commit is purely in-memory (ChannelLedger, crates/client-pull/src/ledger.rs:213) — no fsync, no durability constraint. It is tracked separately in #1484 and can land independently of this issue. The 3.18 ms measured here is server-side only.

Related follow-ups

Activity

  1. added
    prio:high
    rust
    on Jul 27, 2026
  2. added this to the v0.1 milestone 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

prio:highrust

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions