Repository navigation
Deliver the benchmark relay's delayed packets on time (851-4477) - #1489
Merged
pondorasti merged 2 commits intoNov 26, 2026
Merged
Conversation
The Tier 1 relay armed its delivery timer with leeway .never, which macOS 27.2 never fires, so on every simulated network with a delay a packet left only when the next packet reached the relay. That is what froze scroll on the simulated lossy network. Arm the timer with no leeway, reject leeway .never in SwiftLint, and store the host's count of stale reference acknowledgements in the report. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…51-4477) Review fixes: the next delivery was armed from the time the flush began, so it left late by however long the flush took. The lint rule also catches the fully qualified spelling and has a test. The relay test retries an interrupted wait and is named for what it asserts. Co-Authored-By: Claude Fable 5.2 <[email protected]>
pondorasti
deleted the
alexandru/851-4477-screen-sharing-freezes-briefly-while
branch
November 26, 2026 05:39
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.
Part of 851-4477 (PR 1 of 2: benchmark only, no product code. PR 2, the product hardening, will close the ticket.)
What was wrong
The Tier 1 relay armed its delivery timer with
leeway: .never. That reads like "no leeway" but is an infinite one, and macOS 27.2 never fires such a timer. So on every simulated network with a delay (N1 to N7), a packet left the relay only when the next packet in either direction reached it. This has been so since the benchmark was added (28 October, #904). It is what froze scroll on the simulated lossy network (N3) in a quarter to a third of repetitions and made the PR gate fail at random.What changes
leeway: .never(andDispatchTimeInterval.never) everywhere it lints, product code included.stale_ltr_acknowledgements, the host's count of reference acknowledgements it rejected as stale (Tier 1 and Tier 2; absent in older reports).Other timers
Searched every Swift, Objective-C and C file for
leeway,makeTimerSource,dispatch_source_set_timerand timer scheduling. Dispatch timers in the repo:LoopbackRelay.never(this bug)EncodeLabPacer.nanoseconds(0)SourcePusher.nanoseconds(0)ComputerUseRecordingNo product timer has the pattern.
Tests
LoopbackRelayTests: one packet through a relay with a 5 ms delay and no other traffic, both directions. On the old timer line it fails (the packet never arrives within the 2 s guard); with the fix it passes in 7 ms.scripts/swift-lint.test.mjs: the new rule rejects both spellings and accepts.nanoseconds(0). Running lint against the old relay file reports both lines.Tier2V2ReadingsTests: the host's stale-acknowledgement count reaches the report's counters.Lab A/Bs on tamale
All runs are GitHub Actions lab jobs on tamale, baseline (main at 45ec532) against the same commit with only the relay file changed. Each cell is one 30 s repetition after 10 s of warm-up, as in the nightly matrix plan; the two halves of a pair ran within about 25 minutes of each other (other jobs sometimes ran in between). Times are capture to committed, median, in ms, shown as current → fixed.
Six of the seven networks get faster or steadier. The 1 ms networks drop from about 17 to 9 ms and every freeze on N2 to N6 goes away (video on the 30 Mbit/s network goes from 29 to 36 updates per second to a steady 60).
The 1 Mbit/s network (N7) gets worse on scroll, and this is the product, not the benchmark. Because one repetition is too few there, I ran scroll and video on N7 six times per side on each encoder:
Runs: fallback 45757884876 (current) and 45756571502 (fixed); shipped 45759806854 and 45759740238. In every slow repetition the host sent a second start-up keyframe (about 400 KB after the first 193 KB, on a link that carries 125 KB a second), and in the two repetitions that showed nothing the keyframes added up to 1.5 MB. With packets delivered on time this happens to scroll every time; the old relay's clumping hid it most of the time. No product code changes in this PR, so this is what a real 1 Mbit/s link with 5% loss gets today. I have not traced why the first keyframe is given up; that belongs with PR 2 (it is the same family: the viewer asking for packets that are still on their way).
One note on pair 1: its fixed side ran the first version of the fix (the timer line only), before the review fix that re-reads the clock. The PR gate below ran the final code on the lossy network and got the same numbers (9.0, 9.2, 11.5 ms). Pairs 2 to 4 and the N7 runs used the final relay file.
Every cell, with the stored baseline (median of the last 7 nightlies; fallback encoder only, the nightly plans don't run the shipped one)
Fallback encoder (VideoToolbox), networks N1 to N4
Current relay: run 45739913441. Fixed relay (first version of the fix (timer line only)): run 45739926943.
Fallback encoder (VideoToolbox), networks N5 to N7
Current relay: run 45745709795. Fixed relay (final relay code): run 45745699213.
Shipped encoder (VCP), networks N1 to N4
Current relay: run 45750501961. Fixed relay (final relay code): run 45750491206.
Shipped encoder (VCP), networks N5 to N7
Current relay: run 45754941819. Fixed relay (final relay code): run 45754774666.
The PR gate and the nightly baseline
Does a faster result fail the gate? No. The gate's latency rules fire only on a rise, updates per second only on a fall, the freeze share only on a rise. This PR's own gate run (45745567913, the final code) passed: on the lossy network typing 9.0 and 9.1 ms against a stored 16.6, scroll 9.2 and 9.2 against 14.5, video 11.5 and 11.4 against 15.2, and 0 freezes in 18 of 18 repetitions. The good network (no delay) never went through the timer and is unchanged (8.0 → 7.5 and 7.9, 8.1 → 8.1, 10.3 → 10.3).
What misleads until the baseline rolls over. The baseline is the median of the last 7 nightlies of the same plan, so it keeps the old numbers until 4 of the 7 are new.
Proposal to reset (not done here; say which you want).
gh workflow run bench-screen-sharing.yml -f kind=nightly -f plans=gate-v2, about 12 minutes each on tamale, one at a time because they share thescreen-sharing-benchgroup). The gate's median is then all new the same evening. The core and matrix plans only feed reports, so they can roll over on their own. This is what I recommend.What the nightly matrix report will show for N7: scroll's updates per second fall (stored median about 15, now about 5 on the fallback encoder). The PR gate doesn't cover N7, so nothing fails, but it is a real number and worth its own look.
🤖 Generated with Claude Code