perf(latency): tier-0 attribution + tier-1 send-path levers from the latency plan

design/latency-reduction-2026-07.md T0.1/T0.2/T1.2/T1.3:

- T1.2 rate-capped front-loaded pacing: the paced overflow's budget is now
  min(0.9x slack, overflow wire time at ~3x the live encoder bitrate)
  (PUNKTFUNK_PACE_FACTOR, 0 = legacy deadline-only spread). A 300 KB-1 MB
  frame's tail leaves in ~2-5 ms instead of smearing across ~15 ms at 60 fps;
  GameStream schedule byte-identical (pins unchanged).
- T1.3 data-first wire order: packetize emits every block's data shards before
  any parity (per-block parity pools keep all blocks' parity alive for the
  second pass), so lossless completion stops waiting behind the parity tail.
  EOF = last emitted packet; receiver already order-agnostic.
- T0.1 staged 0xCF: HostTiming gains an append-extensible per-stage tail
  (queue/encode/pace us; seal+channel-wait derived as residual) - no cap bit
  needed, old peers read the 13-byte prefix. Joined client-side into
  Stats::host_{queue,encode,xfer,pace}_ms, the OSD detailed tier, and the
  probe's report.
- T0.2 true on-glass present timing: VK_KHR_present_id/present_wait enabled
  when supported; a PresentTimer waiter thread resolves each present id to
  real visibility, replacing the submit-time display stamp (which undercounts
  by up to a refresh and hides a silent-FIFO standing queue).

Validated on .21: core 185 + host 185 tests, pf-presenter 19, clippy
-D warnings across all five touched crates; loss-harness recovery curve
unchanged; C ABI harness round-trips.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-17 19:13:08 +02:00
co-authored by Claude Fable 5
parent c28b10a5b9
commit aedee2a4e3
15 changed files with 779 additions and 94 deletions
+31
View File
@@ -1241,6 +1241,12 @@ async fn session(args: Args) -> Result<()> {
std::collections::VecDeque::new();
let mut host_us_v: Vec<u64> = Vec::new();
let mut net_us_v: Vec<u64> = Vec::new();
// T0.1 host-stage split (extended 0xCF): queue/encode/pace + the derived seal/xfer
// residual. Empty against a host that predates the stage tail.
let mut queue_us_v: Vec<u64> = Vec::new();
let mut enc_us_v: Vec<u64> = Vec::new();
let mut xfer_us_v: Vec<u64> = Vec::new();
let mut pace_us_v: Vec<u64> = Vec::new();
let mut last_rx = std::time::Instant::now();
let started = std::time::Instant::now();
// Stream-duration cap: `--seconds N`, else the 120s default. Ending the loop here reaches the
@@ -1316,6 +1322,14 @@ async fn session(args: Args) -> Result<()> {
let (_, hostnet_us) = pending_split.remove(i).unwrap();
host_us_v.push(t.host_us as u64);
net_us_v.push(hostnet_us.saturating_sub(t.host_us as u64));
if let Some(s) = t.stages {
queue_us_v.push(s.queue_us as u64);
enc_us_v.push(s.encode_us as u64);
pace_us_v.push(s.pace_us as u64);
xfer_us_v.push((t.host_us as u64).saturating_sub(
s.queue_us as u64 + s.encode_us as u64 + s.pace_us as u64,
));
}
}
}
if expected > 0 {
@@ -1399,6 +1413,23 @@ async fn session(args: Args) -> Result<()> {
"host/network latency split (host = capture→sent on the host; network = wire + \
reassembly)"
);
if !queue_us_v.is_empty() {
// The T0.1 per-stage host attribution: queue (capture→submit) → encode
// (submit→bitstream) → xfer (seal/FEC + send-channel wait, derived residual)
// → pace (the microburst spread). The four tile host_us per frame.
tracing::info!(
stage_samples = queue_us_v.len(),
queue_p50_us = pcts(&mut queue_us_v, 0.50),
queue_p95_us = pcts(&mut queue_us_v, 0.95),
encode_p50_us = pcts(&mut enc_us_v, 0.50),
encode_p95_us = pcts(&mut enc_us_v, 0.95),
xfer_p50_us = pcts(&mut xfer_us_v, 0.50),
xfer_p95_us = pcts(&mut xfer_us_v, 0.95),
pace_p50_us = pcts(&mut pace_us_v, 0.50),
pace_p95_us = pcts(&mut pace_us_v, 0.95),
"host stage split (queue → encode → xfer → pace tile the host figure)"
);
}
} else {
tracing::info!("no host timing datagrams (0xCF) — old host; host+network unsplit");
}