icd_shim: the gate's period is the panel's, and a mailbox slot is freed at the compositor's release

JO
2h ago
+275-43

What this is

Two places where a rate the shim books was decided by a constant instead of by the session's own measurements. Both were measured on one uncapped 120 Hz session, and together they are 200 → 330 fps on it.

The gate booked 1e9 / cap against a panel whose measured period is not 1e9 / refresh, so its clock and the display's were two free-running clocks close to each other. The slot park booked a display release for a buffer that was never displayed, so 40 % of the session's commits waited out a bound instead of a release.

The gate's period is the panel's, not the nominal refresh

1e9 / 120 is 8 333 333 ns. The panel measures 8 257 000 ns on Nova and 8 260 500 on Odin 3. The gate slips 76 µs a frame, sweeps the whole vblank interval every ~108 frames, and every frame that lands late of its vblank waits one it did not need — 80-90 fps under a 120 cap on a 120 Hz panel, with the release intervals visibly alternating between one and two periods.

pacing() now delegates to paced_on(cap, latch_grid()): a cap the panel can express is booked as the whole number of the panel's measured periods nearest to it, so the phase never moves and every interval is the same length. A cap the panel cannot express keeps its own 1e9 / cap — 90 on 120 Hz is 33 % from a multiple, and its achieved rate is already quantized by the display.

capown periodbookedreads
3033.333 ms4 × 8.2605 = 33.042 ms30.26
6016.667 ms2 × 8.2605 = 16.521 ms60.53
1208.333 ms1 × 8.2605 ms121.06
9011.111 msunmapped90.00
1446.944 msunmapped144.00

Rounding goes to the nearest multiple, which lands the rate marginally above its nominal, because the multiple is the panel's measured period and not its nominal one. Rounding up instead would cost a whole divisor. The same tolerance means a cap within 2 % of a multiple is served at that multiple even when it is not one — 119 on that panel reads 121.06, +1.73 % — which is the mapping's cost and is documented rather than avoided; the alternative is leaving the cap to beat against the panel.

Pacing is still Off | Clock and Schedule is untouched: this changes the period a gated session books, not the kind of release. Generation keeps its own clock (Declared::Generating takes on_clock), and a session with no reported grid behaves exactly as before, so nothing here reaches LSFG or an X11 present route.

A mailbox slot is freed at the compositor's release

on_buffer_release parked a slot only when the served mode was in its synced set, and that set held MAILBOX. f41381e grew it because choose_live_mode serves both IMMEDIATE and FIFO_RELAXED as MAILBOX: once the key moved from the declared mode to the served one, those two could only stay parked by dragging a genuine mailbox guest in with them.

The two verdicts it collapsed are about different buffers. A mailbox buffer that reaches the panel is scanned for a full period and must be held that long. One that is superseded in the pending slot never was, and nothing else holds it. Parking both holds the latched frames and also waits out the bound for the superseded ones, because only a latched frame is ever released and so only it gets a note.

Odin 3, Hades II, uncapped mailbox, 4 slots, 120 Hz:

parked mailboxthis change
fps (5 samples)200.4330 (328.7-331.0)
hold2.42 periods1.46 periods
slot_waits34 671 / 40 0472 / 59 356
acquire mean3 670 µs15.3 µs
park_timeouts16 1040
notes23 9380
GPU79.9 % @ 607 MHz84 % @ 1050 MHz

commits was 200.4/s against notes 119.8/s — the panel rate — so 40 % of commits had no note to wait for and fell to release_note_limit_ns(). The daemon measures the display's own hold at 1.0-1.5 periods, which is what the 1.46 now is.

The governor followed the load: 607 → 1050 MHz. That is why the GPU reads 84 % on both, and it is the reason the fps gain (65 %) is smaller than the clock gain (73 %) — the frame is not cheaper, there are just more of them.

The set is FIFO and FIFO_RELAXED again, so a mailbox, immediate or FIFO-relaxed declaration all free at the compositor's wl_buffer.release.

What this gives up, recorded rather than buried: a mailbox buffer that does reach the panel can be written again while it is being scanned, so the reuse tear is open on this path by construction. This is the pre-f41381e rule — payload 20261110.1's 342.5 fps is the same rule on the same device — so it is a restored behaviour and not a new one, but it is a real cost and not a footnote. The authority that separates the two buffers is wp_presentation_feedback.discarded: park what was latched, free what was discarded. It is not subscribed yet (present::expect_feedback requests nothing when the present carries no id, so the census reads presented=0 discarded=0), and that is the follow-up this leaves open.

Verified

  • 135 tests pass, cargo clippy --all-targets -D warnings clean.
  • Gate: five tests over the mapping — the divisor cells, a cap the panel cannot divide, the cap-just-off-a-divisor boundary pinned on both sides, a cap above the panel keeping its own period, and a delayed release that does not overrun.
  • Slot: measured on device, the table above, from a build of 23732f5 with only this diff on top ([shim 202611211203 23732f5-dirty]), 180 s, five census samples.
  • Not yet measured: a capped session after the mapping — cap=120 on 120 Hz should show gate=clock with acq_spacing collapsing into the 8.26 ms bucket. The uncapped session the fps table comes from has cap=0 gate=off, so it says nothing about the gate.
  • Not yet measured: whether the reuse tear is visible at 330, and whether it changes as the rate crosses the panel rate.
  • docs/10's gate section, the two rate claims above its table and the census sentence are corrected with it; the earlier "within 1 %" was wrong in direction and in size, and "the limit is a maximum by construction" is now qualified to the booked period. docs/10 and docs/15 both claimed the hold follows the served mode and that both served modes are synced; corrected with the measurement.