Skip to content

Add the screen sharing bench observer, clock probes, samplers and calibrations (851-3592) - #893

Merged
pondorasti merged 1 commit into
mainfrom
alexandru/851-3592-screen-sharing-v2-t3-black-box-instrument-sck-observer-clock
Oct 29, 2026
Merged

pondorasti merged 1 commit into
mainfrom
alexandru/851-3592-screen-sharing-v2-t3-black-box-instrument-sck-observer-clock

Conversation

@pondorasti

Copy link
Copy Markdown
Member

Part of 851-3592

The black-box instrument for screen sharing v2 (benchmark design §2, §4, §5): the SCK observer, UDP clock probes, CPU/energy and bitrate samplers, and calibrations C1, C2 and C6 as calibrate checks. A follow-up PR will bring the acceptance numbers from the lab minis, which are waiting on the Screen Recording, Accessibility and Local Network grants.

Library (ScreenSharingBench)

  • Clock probes. BenchClockProbeResponder / BenchClockProbeClient send 40-byte probes over UDP. Receive times are kernel timestamps (SO_TIMESTAMP_MONOTONIC).
  • BenchClockTrack: a ±30 s windowed fit with a leave-one-out residual. Over 10 minutes under CI load, a single line missed the minis' clock offset by up to 0.87 ms; the windowed fit stays within about 0.10 ms. ε measured mini↔mini is 0.341 ms.
  • Clock domain. BenchMachClock reads continuous time, and BenchClockOffsetRead gives an exact, signed continuous − absolute offset. Everything the instrument writes is mach continuous ns. SCK's PTS is mach absolute (it equals displayTime to the ns).
  • Samplers. BenchProcessUsage / BenchProcessLoad read proc_pid_rusage V6 (CPU ticks converted to ns, plus energy). BenchInterfaceCounters / BenchInterfaceRate read 64-bit counters via NET_RT_IFLIST2. BenchProcesses finds processes by name.
  • Observer. BenchCapturedFrame turns SCK frames into observations. BenchObserverLog is the JSONL: a header that names its clock, then (version, pts_ns, callback_ns) per frame, with unreadable frames kept. Also BenchObservedVersions, BenchObserverAgreement (C1) and BenchInputResponses (C6/I2P).

App (CodevisorBench)

  • observe: by default an SCK stream of only the barcode strip, which reports the observer's own CPU and power.
  • calibrate --check c1 | c2 (--serve / --responder) | c6 | on-glass. On-glass drives the real ScreenSharingMetalView and 851-3583 frame timeline with barcode frames, and reports on-glass, display-link estimate and presentedTime minus observer PTS.
  • sample: per-second process CPU and power, and interface Mbit/s.
  • scripts/run-installed.sh (which run.sh now uses), plus the steps for the workflow_dispatch workflow .github/workflows/screen-sharing-bench-calibration.yml (tamale and croissant jobs, concurrency group screen-sharing-bench).
  • NSLocalNetworkUsageDescription in Info.plist. Without Local Network, UDP to the other mini fails with EHOSTUNREACH.
  • T2's PlayerCPUClock is replaced by the shared proc_pid_rusage meter.

Verification

  • swift test for ScreenSharingBenchTests and CodevisorBenchTests: 49 + 4 pass. The pre-commit bun run check passed: Swift format, lint and tests, and the iOS build.
  • On the lab minis, with a loose ad-hoc copy of this binary over ssh: C2 for 15 s gave ε 0.339 ms and residual 0.043 ms. The two 10-minute runs are analysed on the ticket.
  • On the MacBook Pro's built-in display: on-glass gave C1 |ΔPTS| = 0 over 597 versions, presentedTime − SCK PTS = +7.83 ms (constant), and displayLinkTarget − SCK PTS of −0.49 ms p50 and +7.85 ms p95.
  • The PTS clock domain was checked against displayTime: 0 ns over 173 frames.
  • Code review at level high ran twice. The valid findings are fixed: workflow gating and idle exit, transient socket errors, ambiguous input events, draining records after the settle, the per-observer clock offset, and exit 1 on a failed calibration.

🤖 Generated with Claude Code

…ibrations (851-3592)

The black-box instrument for screen sharing v2. In ScreenSharingBench:
clock probes over UDP with kernel receive timestamps, a windowed clock
track (the minis' relative rate wanders with load), process CPU/energy
and interface byte samplers, and the observer's frame decoding, JSONL
log, first-seen versions, C1 agreement and input pairing. In
CodevisorBench: observe, calibrate (c1, c2, c6, on-glass) and sample,
plus a workflow_dispatch calibration workflow for the minis.

Part of 851-3592

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