Repository navigation
Don't count a request for a packet that was only late as loss (851-4501) - #1515
Merged
Merged
Conversation
The viewer counts, per frame, the packets it asked for whose first copy arrived too soon to be the resend, and reports them with the frame's receipt behind a new feedback flag. The host takes them back off the one-second loss window, and waits for frames that can still answer before the heavy-loss rule reads it. On a jittery link a pause in arrivals during a large frame made the viewer ask for packets still on their way, and the heavy-loss cut collapsed the estimate. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…fore it rolls (851-4501) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…and keep the probe's copy and resolved frames out of the way (851-4501) What the last review found: - A taken-back packet also comes off the estimator's lost bytes. - When every loss of the frame that last set the FEC trigger is taken back, the trigger goes back to what it was. - The last packet isn't charged when a tail probe's copy is on its way, so an early probe copy can't cancel a loss. - A frame resolved by a later frame's report keeps its charges until its own report arrives. - Feedback with more than eight late ranges keeps the first eight, and feedback cut short keeps none, instead of being dropped; ranges are clamped to the frame. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… back from the request that charged them (851-4501) What the review of the take-back found: - Restoring one earlier FEC-trigger time could leave a taken-back loss in place or clear another frame's real one. Each frame's requested losses now count apart, and a frame stops keeping FEC on only when none of them stands. - A frame with a probed last packet or a resent repeat stays a loss. - Lost bytes come off the estimator entry of the request that charged them, not the newest one. - A frame resolved by a later frame's report also holds the loss window until its own report arrives. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… was charged in the window before (851-4501) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d bytes out of the drop check until answered (851-4501) From the review of 3a1ff75: - A request that came while an ended window waited was counted in it, and the window rolled before its report. Each frame now belongs to the window it was sent in: frames sent after a window's second count, with their losses, in the next one, and an ended window waits for each of its own frames' reports (at most 2 s old). - Requested bytes reached the estimator's drop check at once and stayed after a take-back. They now reach it only when their frame is answered, at the time they were requested; late ones never do. - A late packet the arrival count had taken as lost is given back to it. - LateOriginals::from_indices sorts and dedups its input; the README matches the code. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he frame's own answer, and fix two windows (851-4501) What the review of d93998935 found: - Held lost bytes dated at a request more than 500 ms before the answer missed the drop check; they now land no earlier than 250 ms before the answer. - The roll confirmed frames resolved by a later report before their own report could take late packets back; only the frame's own report or its eviction confirms it now. - A give-back after the arrival count restarted took bytes off another loss; it now checks the count's generation. - A parity repair counted in the current window; it counts in the window its frame was sent in. Co-Authored-By: Claude Opus 5.5 <[email protected]>
pondorasti
force-pushed
the
alexandru/851-4501-spurious-loss
branch
from
November 28, 2026 00:22
3a1ff75 to
e252d69
Compare
…nd clamp only answered losses (851-4501) What the review of the last commit found: - A frame resolved by a later report whose own report was lost never confirmed its losses; it now confirms after the same two round trips and a frame interval the host already gives that report. - Losses of frames given up after an outage all landed in the drop check at once; only answered frames are clamped into its 500 ms now, and given-up ones keep their request times. - The clamp is measured from the last send when that is earlier than the answer. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ken back once it reached the estimate (851-4501) From the review of b8c0566: - A frame resolved early whose own report never came reached the drop check only at the next roll, dated too early for it to look; it is now confirmed when its wait ends (timeout or feedback), dated then. - Confirming clears the frame's charges, so a later report can't lower the window or give bytes back to the arrival count while the estimator keeps the loss. - A packet sent again for a repeated request reaches the estimator at once and can't be taken back. - A frame with nothing left standing stops holding the window; the late ranges sit after the LTR bytes whenever the LTR flag is set. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes 851-4501
On the 50 Mbit/s lab network (25 ms ± 5, 0.1% loss) the host's rate estimate collapsed to about 3 Mbit/s for the rest of a run. This PR stops the host from counting a request for a packet that was only late as a loss.
What was wrong
A pause in arrivals during a large frame makes the viewer ask for packets that are still on their way: 30–170 of them in the traced runs. The host counted each request as a loss, so its one-second loss window read 13–32% on a link that loses 0.1%. The heavy-loss cut then threw the measured rate away, and the estimate fell to the next small sample, about 3 Mbit/s. In 16 traced local runs of fallback scroll on that network, 5 of 8 collapsed on main.
What changes
All of it is in the Rust transport (
codevisor-media).The crate README has the details.
Lab: 50 Mbit/s network, six repetitions, same slot
Main at 1a74aba against this branch at d628636 (before the last commit, which only affects lost bytes charged in the window before a roll). Runs 46074689338/46075450387 (fallback) and 46077293111/46078087630 (shipped).
Median updates/s and latency are unchanged or better: shipped video p95 64.9 → 59.4 ms.
Low estimate at the start of some video runs: didn't repeat. In the pair above, 4 of 12 video runs with this PR started at 5–7 Mbit/s and none on main. Two video-only same-slot pairs followed, both encoders and six repetitions each, with the starting estimate (lowest in the first 6 s) per run:
No gaps over 500 ms anywhere. So the earlier 4 of 12 was chance. The second pair ran one commit before the head (b8c0566). That commit only changes when held losses of frames resolved early, or given up, reach the drop check.
At a session's start, this PR covers least: the first keyframe's queue can hold its packets past half the lowest round trip, and those aren't recognised as late.
The 1 Mbit/s hitches are a different path
The question from #1510 was whether the extra 250–500 ms gaps on the 1 Mbit/s network come from this spurious-loss path. They don't. In 4 interleaved local traced runs per side (fallback scroll on N7):
These are local runs, not lab numbers.
Tests
New unit tests in
sender.rs,estimator.rs,arrived.rsandwire.rs, each checked to fail without its fix. They cover:Sim tests in
tests/core.rscover a late keyframe tail at any moment of the window, a real tail loss still counting, and cross-window cases. No existing assertion is loosened. Three earlier unit tests that expected requested bytes in the estimate at once now expect them on the answer.Run locally (M1 Pro, with timeouts):
cargo test -p codevisor-media(78 unit, 63 sim, 6 session tests), plus clippy.ScreenSharingV2Tests206,ScreenSharingBenchTests98,CodevisorBenchTests61.a_slow_link_doesnt_ask_again_for_packets_still_on_their_waysits close to its floor: its lowest estimate (500 kbit/s floor on 1 Mbit/s) dropped to 0.46 when the ended window's wait was bounded at one second plus two answer times. It passes with the 2 s bound.Code review
Your review at 3a1ff75, all five fixed:
from_indicessorts and deduplicates its input.Code-review skill on the fixes (two rounds). Fixed:
Your review at b8c0566. Fixed, each with a test that fails without it:
Also changed, though no test can fail without them:
Left:
🤖 Generated with Claude Code