Skip to content

Add the Tier 1 loopback benchmark with an emulated network (851-3593) - #904

Merged
pondorasti merged 2 commits into
mainfrom
alexandru/851-3593-screen-sharing-v2-t4-tier-1-in-process-loopback-benchmark
Oct 29, 2026
Merged

pondorasti merged 2 commits into
mainfrom
alexandru/851-3593-screen-sharing-v2-t4-tier-1-in-process-loopback-benchmark

Conversation

@pondorasti

Copy link
Copy Markdown
Member

Part of 851-3593

Summary

Adds CodevisorBench loopback, the Tier 1 benchmark from the design (§4.2). It streams the S1–S6 scenes through the product ScreenSharingSender and ScreenSharingReceiver in one process, over an in-process UDP relay that emulates N0–N7, and writes report v1.

  • The product, not a copy. It uses the ScreenSharingProductProfile from Share one screen sharing product profile between the host and the bench (851-3593) #894, the product field trials and the adaptive quality loop. The viewer renders through the product render coordinator and Metal encoder into an offscreen texture. With --onscreen, the product ScreenSharingMetalView shows it in a window.
  • Relay. Each peer's SDP is rewritten to one host candidate on a relay socket, using ScreenSharingTunnelSDP. Both directions go through BenchRelayLink, which wraps the T1 BenchNetworkModel (seeded loss, delay, jitter, capacity, queue). Each peer socket gets its own mapping socket, like a NAT, so every ICE pair goes through the relay. The report records the first lost packet indices per direction.
  • Sources.
    • synthetic: BenchSceneGenerator on a 60 Hz tick, pushed only when the version changes, rendering up to three ticks ahead.
    • own-window: the player window, captured by the product ScreenSharingCapture via SCShareableContent.currentProcess.
  • Report v1 additions (in ScreenSharingBench):
    • e2e_ms and e2e_endpoint (capture → committed, or on-glass);
    • stages_ms from the 851-3583 timeline;
    • timing_frame_check: WebRTC timing frames matched to timeline frames by capture time;
    • relay statistics;
    • codec_errors;
    • bitrate measured at the relay.
  • Clock domains. Timeline timestamps (mach absolute) are shifted to mach continuous once per scene before they're joined with the bench library.
  • Workflow. .github/workflows/screen-sharing-bench-loopback.yml is a workflow_dispatch job pinned to tamale, in concurrency group screen-sharing-bench. It runs scripts/loopback.sh: back-to-back full matrices plus the own-window run, then uploads the reports. It has to be on main before it can be dispatched, which is why this PR lands before the acceptance runs. The results go on 851-3593 and in the final PR.

Product changes are access levels only:

  • the Metal encoder, TextureFrame and the shader become package;
  • ScreenSharingCapture.start(filter:);
  • ScreenSharingPeer.statistics(including:), so googTimingFrameInfo can be read;
  • BenchUDPAddress sockaddr access.

ScreenSharingTunnelSDP also gains localIPv4Candidate, which returns the candidate's port. No behaviour or performance changes in the product pipeline.

Checks

  • Swift tests:

    • new BenchRelayLinkTests, BenchLoopbackAnalysisTests and BenchTimingFrameCheckTests;
    • a 4:4:4 barcode read;
    • the golden report;
    • the tunnel SDP port;
    • ScreenSharingBenchTests (61), CodevisorBenchTests, ScreenSharingTunnelSDPTests and ScreenSharingProductProfileTests pass.
  • The pre-commit bun run check passed on both commits. Earlier attempts failed in ScreenSharingCodecRoundTripTests / ScreenSharingEncoderRateControlTests with Create encoder (-12903), because another agent's stress run held the hardware encoders; they passed once those runs finished.

  • code-review at level high, twice. I fixed:

    • cleanup when a scene fails;
    • matched timing frames;
    • socket leaks;
    • reuse of BenchUDPAddress and ScreenSharingTunnelSDP;
    • the drain;
    • send failures;
    • adapt order;
    • pre-render waste;
    • the output path check.

    I'm leaving three:

    • own-window captures in the profile codec's pixel format, while the product captures in the negotiated codec's; they're the same unless the hardware falls back;
    • RelaySocket stays separate from the blocking probe socket;
    • spotlight_busy isn't measured yet, which is T5's preflight (C5).
  • Smoke runs on tamale over SSH were for development only. Acceptance numbers come from the workflow.

🤖 Generated with Claude Code

pondorasti and others added 2 commits October 28, 2026 22:56
`CodevisorBench loopback` streams the S1–S6 scenes through the product
ScreenSharingSender and ScreenSharingReceiver (ScreenSharingProductProfile,
the product field trials and the adaptive quality loop) in one process. The
viewer renders through the product render coordinator and Metal encoder
offscreen, or in a window with --onscreen.

- An in-process UDP relay rewrites each peer's SDP to one host candidate on
  a relay socket. It forwards both directions through BenchRelayLink, which
  wraps the T1 BenchNetworkModel for N0–N7: seeded loss, delay, jitter,
  capacity and queue. Each peer socket gets its own mapping socket, like a
  NAT, so every ICE pair goes through the relay.
- Sources: synthetic (BenchSceneGenerator, pushed on version change at
  60 Hz) and own-window. The own-window source captures the player's window
  through the product ScreenSharingCapture, found with
  SCShareableContent.currentProcess.
- Report v1 gains e2e_ms with e2e_endpoint (capture to committed, or
  on-glass), stages from the 851-3583 timeline, timing_frame_check (WebRTC
  timing frames matched to timeline frames), relay statistics with the
  first lost packet indices, codec_errors and bitrate from the relay.
- Clock domains: timeline timestamps (mach absolute) are shifted to mach
  continuous once per scene before they're joined with the bench library.

`.github/workflows/screen-sharing-bench-loopback.yml` (workflow_dispatch,
pinned to tamale, concurrency group screen-sharing-bench) runs
scripts/loopback.sh inside one job: back-to-back full matrices plus the
own-window run, then uploads the reports. T3's calibration and the
loopback share scripts/record-installed-commit.sh.

Product code changes are access levels only (the Metal encoder, the
capture's filter start and a statistics overload for extra fields), plus
ScreenSharingTunnelSDP returning the candidate's port. Nothing in the
product pipeline changes behaviour.

Part of 851-3593

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Drain each scene until the relay has delivered everything it holds (up to
  5 s), so slow links don't lose the tail of the window.
- Count relay send failures in the report (`send_failures`).
- Adapt the source before the sender, close the sender if the receiver
  can't be created, and pre-render only the ticks that will be shown.
- Check --output and --frames before the matrix runs.

Part of 851-3593

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@pondorasti
pondorasti merged commit 30d1344 into main Oct 29, 2026
@pondorasti
pondorasti deleted the alexandru/851-3593-screen-sharing-v2-t4-tier-1-in-process-loopback-benchmark branch October 29, 2026 06:09
pondorasti added a commit that referenced this pull request Oct 29, 2026
…93) (#905)

#895 added `presentsWindows` to BenchCommand while #904 was in review, so
LoopbackCommand no longer conformed once both landed. Loopback presents
windows with --onscreen or the own-window source. Also schedule the barcode
verifier's drain from a method, so the tap callback doesn't capture a weak
self var across queues.

Part of 851-3593

Co-authored-by: Claude Opus 5.5 <[email protected]>
dylanplayer added a commit that referenced this pull request Oct 29, 2026
Since #904, CodevisorBench links ScreenSharingWebRTC, so its test bundle
needs WebRTC.framework at runtime. Without the @loader_path/../../.. rpath
that the other WebRTC test targets carry, the bundle failed to dlopen and
swift:test (and so the pre-commit hook) failed on every machine. CI's
Build doesn't run Swift package tests, so main stayed green.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant