The control loop stops believing its own bookkeeping #403

Merged
enricobuehler merged 1 commits from worktree-abr-control-loop into main 2026-08-26 18:15:00 +00:00
Owner

ABR overhaul Phase 2 (planning PR #20, RFC §3 — signed off): the four correctness seams from the 08-22 review's §2, with the RFC's chosen options. Parallel-safe with #401 — no climb relaxation among them.

  • §2.3 phantom rate: the control task acks a SetBitrate before the data plane applies it; when the fallback rebuild failed, the client kept climbing from a rate the encoder never ran. The failure arm now sends the live rate through retarget_tx — the same channel as the existing short-apply correction three lines up.
  • §2.2 missing PipelineGap: the adaptive-bitrate rebuild (~0.6 s stall) is the one rebuild that never announced — its starved window read as congestion, killed slow start, and the 401 ms field case sat minutes at ~15 Mbps on a clean link. The success arm now announces the timed gap, exactly like the mode-switch and topology arms.
  • §2.1 stale stream cap: the stream-shape cap was computed once from the Welcome mode. An accepted mode switch now re-teaches it in the pump (mode from mode_slot, codec/depth/chroma carried as session constants), and a re-set set_stream_cap rebinds an already-learned ceiling downward (set_ceiling deliberately never lowers). The first set keeps the founding semantics — a negotiated start above the cap stands — pinned by the existing the_stream_bound_clamps_a_learned_ceiling_only.
  • §2.4 latest-wins ack slot: bitrate_ack becomes a queue drained in arrival order per report window. A full resolve ack plus a corrective short retarget in the same 750 ms window used to collapse to whichever arrived last, and host-cap learning needs two consecutive short acks — a lost correction could reintroduce the encoder-overdrive sawtooth.

Verified: punktfunk-core --features quic — all 490 lib tests green natively (macOS), including the new a_mode_switch_reteaches_the_stream_cap_both_ways; cargo fmt --check clean. The host-side arms (§2.2/§2.3, stream.rs) lean on ci / rust.

ABR overhaul **Phase 2** (planning PR #20, RFC §3 — signed off): the four correctness seams from the 08-22 review's §2, with the RFC's chosen options. Parallel-safe with #401 — no climb relaxation among them. - **§2.3 phantom rate**: the control task acks a `SetBitrate` *before* the data plane applies it; when the fallback rebuild failed, the client kept climbing from a rate the encoder never ran. The failure arm now sends the live rate through `retarget_tx` — the same channel as the existing short-apply correction three lines up. - **§2.2 missing `PipelineGap`**: the adaptive-bitrate rebuild (~0.6 s stall) is the one rebuild that never announced — its starved window read as congestion, killed slow start, and the 401 ms field case sat minutes at ~15 Mbps on a clean link. The success arm now announces the timed gap, exactly like the mode-switch and topology arms. - **§2.1 stale stream cap**: the stream-shape cap was computed once from the Welcome mode. An accepted mode switch now re-teaches it in the pump (mode from `mode_slot`, codec/depth/chroma carried as session constants), and a *re-set* `set_stream_cap` rebinds an already-learned ceiling downward (`set_ceiling` deliberately never lowers). The *first* set keeps the founding semantics — a negotiated start above the cap stands — pinned by the existing `the_stream_bound_clamps_a_learned_ceiling_only`. - **§2.4 latest-wins ack slot**: `bitrate_ack` becomes a queue drained in arrival order per report window. A full resolve ack plus a corrective short retarget in the same 750 ms window used to collapse to whichever arrived last, and host-cap learning needs two *consecutive* short acks — a lost correction could reintroduce the encoder-overdrive sawtooth. **Verified:** `punktfunk-core --features quic` — all 490 lib tests green natively (macOS), including the new `a_mode_switch_reteaches_the_stream_cap_both_ways`; `cargo fmt --check` clean. The host-side arms (§2.2/§2.3, `stream.rs`) lean on `ci / rust`.
enricobuehler added 1 commit 2026-08-26 17:10:52 +00:00
The control loop stops believing its own bookkeeping (ABR overhaul Phase 2)
apple / swift (pull_request) Successful in 2m16s
apple / distribute (pull_request) Skipped
apple / screenshots (pull_request) Skipped
ci / rust-arm64 (pull_request) Successful in 2m13s
ci / bun-nix (pull_request) Successful in 23s
ci / docs-drift (pull_request) Successful in 26s
android / android (pull_request) Successful in 5m44s
ci / docs-site (pull_request) Successful in 3m59s
ci / web (pull_request) Successful in 4m35s
ci / rust (pull_request) Successful in 9m53s
windows-client / client (x64, , x86_64-pc-windows-msvc, C:\t) (pull_request) Successful in 6m21s
windows-client / client (arm64, --no-default-features, aarch64-pc-windows-msvc, C:\t-a64) (pull_request) Successful in 2m56s
5bf64e07bf
The four correctness seams from the 08-22 auto-bitrate review §2, chosen
options per the RFC (planning design/abr-stack-overhaul.md §3):

- §2.3: a failed bitrate-change encoder rebuild now snaps the client back
  (retarget_tx) — the control task acks BEFORE the apply, so the client's
  climb base, utilization and proven math tracked a rate the encoder
  never ran until some later event happened to correct them.
- §2.2: the ABR rebuild announces PipelineGap on success, like the
  mode-switch and topology rebuilds already do — a ~0.6 s host-local
  stall read as congestion killed slow start for the session (the 401 ms
  field case: minutes at ~15 Mbps on a clean link).
- §2.1: an accepted mode switch re-teaches the stream-shape cap —
  computed once from the Welcome mode, 1080p→4K kept a 1080p-sized climb
  ceiling and 4K→720p left an oversized one standing. A re-set
  set_stream_cap also rebinds the already-learned ceiling downward
  (set_ceiling deliberately never lowers); the FIRST set keeps the
  founding semantics, pinned by the existing stream-bound test.
- §2.4: the bitrate_ack slot becomes a queue drained in arrival order —
  latest-wins collapsed a full resolve ack + corrective short retarget
  landing in the same 750 ms window, and host-cap learning needs two
  CONSECUTIVE short acks.

punktfunk-core --features quic: 490 tests green natively, including the
new a_mode_switch_reteaches_the_stream_cap_both_ways.
enricobuehler merged commit c1bffa9e7b into main 2026-08-26 18:15:00 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: unom/punktfunk#403