Skip to content

Classify a late in-progress flag as an in-gate start, and spend budgets as deadlines (Re Sodalite#49) - #338

Merged
superuser404notfound merged 1 commit into
mainfrom
fix/49-start-classification-and-deadlines
Aug 8, 2026
Merged

superuser404notfound merged 1 commit into
mainfrom
fix/49-start-classification-and-deadlines

Conversation

@superuser404notfound

Copy link
Copy Markdown
Owner

Second round of measurement work on Sodalite#49. The reporter's three new logs are the first unfiltered ones, and they settle one question, expose two defects in the instrumentation, and produce one number worth keeping.

What the logs settle

The panel is innocent for the third time: content=29.970 → panel nominal 59.943 in all three runs. And the judder is gone on the current build.

Defect 1: pre-gate was reported for a switch that started inside the gate

All three runs came back start pre-gate, including the flipped run at after 376ms. Stage 1 tested isDisplayModeSwitchInProgress on every poll but drew the conclusion StartSignal.preGate documents for the first one only ("already set when polling began"). A flag observed false at entry cannot describe a switch that predates entry, so that run was logged as the exact ordering the issue was filed on while being its opposite.

classifyStart is now a pure function with a third case, inGateFlagOnly, for a flag that rises later with no start notification. The switch began inside the gate either way; the missing piece is the notification, which points at the observer registration point (they are registered on gate entry) rather than at the panel.

Defect 2: budgets were poll counts, not deadlines

n sleeps of m ms is only n * m on an idle scheduler. The reporter's Apple TV reports thermal=serious from the first sample onward in all three logs, and the same 40 x 50 ms Stage 2 took 2082 ms in one run and 2862 ms in another. Both stages now measure elapsed time against budgetMs / stage2CapMs.

This is the second measurement defect in a row on this path; the first one (#279) inflated every settle time by the whole Stage 1 budget.

The number worth keeping

The flipped run is the only one where the panel ever reported an end, and it came at 3238 ms total (2862 ms after the start was seen). Two of three runs instead hit the Stage 2 cap with no end reported at all, both rate-only SDR. So on this panel a rate-only switch is neither sub-second nor reliably observable, which contradicts the d87b54d premise .brief rests on.

Not changed here: the cap is not raised and .brief is not widened. One panel is not grounds for making every session's cold start wait longer, and the runs that produced these numbers played cleanly. The measurements are in the doc comments so the next change to those budgets starts from evidence rather than from a premise.

Also not changed, deliberately

Registering the switch observers at the criteria write instead of at gate entry would be the real fix for "end never reported", and inGateFlagOnly is precisely the evidence that would justify it. It touches apply(), the path carrying DV P5 cold start, #133 and #176, and it cannot be verified without hardware. The order that was missing last time: be able to measure first, then rebuild. If the next round shows inGateFlagOnly dominating, the rebuild has a target and a way to tell whether it worked.

Tests

23 in the suite, 7 new, covering the classification table and the deadline behaviour with the reporter's two measured cap durations as cases. Full run: 1631 tests in 241 suites green, plus a generic/platform=tvOS build, since the changed loops sit under #if os(tvOS) and swift test on macOS never compiles them.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HX5zV3Fcf7Nzq4DYGdXvQE

…nd spend budgets as deadlines (Re Sodalite#49)

The first measurement round made the reported settle times real. The second
round showed the signal they hang off is not: all three reporter runs came
back `start pre-gate`, including one whose in-progress flag was demonstrably
false for the first 376 ms.

Stage 1 tested `isDisplayModeSwitchInProgress` on every poll but drew the
conclusion the enum only licenses for the first one. A flag observed false at
entry cannot describe a switch that predates entry, so that run was logged as
the ordering Sodalite#49 was filed on while actually being its opposite. The
new `inGateFlagOnly` case keeps the two apart: the switch began inside the
gate either way, and what is missing is the start notification, which indicts
the observer registration point rather than the panel.

Both stages also spent poll counts rather than deadlines. `n` sleeps of `m` ms
is only `n * m` on an idle scheduler, and the reporter's Apple TV runs
`thermal=serious` throughout: the same 40 x 50 ms Stage 2 took 2082 ms in one
run and 2862 ms in another. A budget with a 40 % spread under the load it
exists to survive is not a budget, and this is the second measurement defect
in a row to make these logs unreadable. Stage 1 and Stage 2 now measure
against `budgetMs` / `stage2CapMs`.

Deliberately not changed: the cap is not raised and `.brief` is not widened.
The reporter's panel has now been measured at ~2.9 s for a rate-only SDR
switch, which does contradict the d87b54d sub-second premise, but one panel is
not grounds for making every session's cold start wait longer, and the runs
that produced these numbers played cleanly. The doc comments carry the
measurements so the next change to those budgets starts from evidence.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01HX5zV3Fcf7Nzq4DYGdXvQE
@superuser404notfound

Copy link
Copy Markdown
Owner Author

One behavioural consequence worth deciding before this merges

The deadline change is not purely cosmetic for Stage 1, and I understated that in the description.

.full was 100 iterations of Task.sleep(10ms). On an idle scheduler that is the documented 1000 ms. Under the load these logs were captured at, it is not: the same drift that stretched Stage 2's 40 x 50 ms to 2862 ms applies here too, and short sleeps carry proportionally more overhead than long ones. So the effective Stage 1 wait under load has probably been somewhere north of 1000 ms, and this change makes it exactly 1000 ms.

That is a shortening, and it lands on the one guarantee this gate exists for: DV Profile 5 cold start, where starting the decode before the switch begins races an AVPlayer error. #274 verified the budget against the log line that printed budgetMs, i.e. against the nominal number, so a longer real wait would not have shown up in that verification either.

Three ways to read it:

  1. Correct as written. 1000 ms is the documented, reviewed and waitForSwitch() still runs when suppressDisplayCriteria=true, adding a residual startup wait even when the host is the sole criteria writer #274-verified value. If the real wait was longer, that was an accident, and restoring the intended value is the fix rather than a regression.
  2. Deadline for Stage 2 only, leaving Stage 1 counting ticks. Removes the risk, keeps the inconsistency, and leaves Stage 1's reported budget still not matching its real one.
  3. Deadline for both, with .full re-sized to whatever the effective wait has actually been. No number to base that on today.

I have left it at 1, because the alternative is keeping a budget that is only correct when nothing else is happening. But it wants a DV P5 cold start on hardware before it ships, not just green CI, and that is not something the test suite can cover.

@superuser404notfound
superuser404notfound merged commit 9e45d2a into main Aug 8, 2026
3 checks passed
@superuser404notfound
superuser404notfound deleted the fix/49-start-classification-and-deadlines branch August 8, 2026 21:17
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