Skip to content

Bound the player's text prewarm drain by time, not string count - #376

Merged
GLinnik21 merged 1 commit into
mainfrom
perf/text-prewarm-drain-budget
Oct 1, 2026
Merged

GLinnik21 merged 1 commit into
mainfrom
perf/text-prewarm-drain-budget

Conversation

@GLinnik21

Copy link
Copy Markdown
Collaborator

What

The player's text prewarm drain (PanelMotion::drain_queued_text) was bounded by string count only: eight live strings per presenting frame. A string costs 1–3 ms on the television, so one drain could take most of a frame or more. The drain is now bounded by time: PREWARM_BUDGET_US = 2.5 ms per presenting frame, with a floor of one string so the queue always advances.

  • The live queue (strings the visible page is about to draw) drains first; the parked background queue (the other tab) only gets what the live queue left.
  • The clock comes in from app/run.rs (heartbeat::now_us); nothing under ui/ reads the wall clock.
  • A string the budget leaves queued is rasterised on demand when it is drawn, as before prewarm existed.
  • ClockWarm is a client of the same queue and falls under the same budget.

Measured on the television (2026-10-02, guest profile, mock server, player with the track menu opened by the menu=1 trigger)

before (6ee274c) after (bd11fe4)
warmdrain on the menu-open frame 9.8 ms and 6.6 ms (two legs) 3.3 ms and 3.2 ms (two consecutive frames)
menu-open frame total 21.7 ms and 17.8 ms 14.8 ms and 18.3 ms
drains over 3 ms in the leg 11 5

Not fixed: one frame about 1.1 s after playback start still spends 18.9 ms in the drain (22.7 ms before). It is a single string, so the one-string floor admits it whole; which string, and why it costs that much, was not investigated.

This does not change the steady-state back-buffer waits. The same capture session showed those follow an on-time commit in 29 of 31 cases and the GPU is idle while the frame waits; the write-up is in the tooling PR.

Verification

  • Regression test ui::panel_motion::tests::a_drain_stops_at_its_time_budget_and_the_rest_carries_over_live_first, red before the change with frame 1 rasterised 7, budget admits 3.
  • make check on the committed tree: test result: ok. 5447 passed; 0 failed; 7 ignored, test result: ok. 102 passed; 0 failed, test result: ok. 5527 passed; 0 failed; 7 ignored.
  • cargo +nightly check --lib --no-default-features: rc=0. ARM cross-build: rc=0.
  • One 35 s leg on the television with the panel off; text pop-in was not checked visually.

🤖 Generated with Claude Code

…ve queue first

The drain was bounded by string count (eight live, one background), but a string costs 1-3 ms
on the television, so one presenting frame spent warmdrain:22.7 at playback start (total 34.9),
warmdrain:15.8 at 0.0 s and warmdrain:9.8 on the track menu's open frame. The drain now takes a
microsecond clock (the product passes the heartbeat clock, host tests a counted one) and spends
at most PREWARM_BUDGET_US, always at least one string; the parked other-tab queue only gets what
the live queue leaves. Strings left over are rasterised by the draw on demand, as before prewarm.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@GLinnik21
GLinnik21 merged commit 600edd0 into main Oct 1, 2026
9 checks passed
@GLinnik21
GLinnik21 deleted the perf/text-prewarm-drain-budget branch October 1, 2026 23:30
GLinnik21 added a commit that referenced this pull request Oct 1, 2026
… back-buffer-wait capture showed (#377)

The first TV run read the non-consuming `trace` file, which re-walks the ring on every read on the
4.4.84 kernel: 3.3 s of data took about nine minutes, the ring had overrun, a third of the events
were arch-timer noise and no syscall events were enabled for the analyser.

The read-back now drains trace_pipe on the set (gzipped there), ends when the per-CPU stats show an
empty buffer, and is bounded on the host by --read-timeout (default 90 s); a stopped read-back keeps
what arrived as a valid gzip. Entries and overrun are printed per CPU. The arch timer is filtered
out of the irq events (string filter, falling back to irq numbers). The ring is sized for the
capture and capped at 32 MB. --tid N enables raw_syscalls for that thread. Restore clears all of it.
tools/test_tv_sched_trace.py drives the script against a fake tracefs and a fake tv-ssh and is
wired into check-python.

docs/player-submenus.md replaces the "next TV session" plan with the results: the GPU is idle
during the long waits; osd_irq paces commits at 8.33 ms; 29 of 31 steady-state waits of 18 ms or
more followed an on-time commit and are the compositor's, 2 followed platform threads preempting
the frame thread; the text prewarm drain was unbounded (fixed in #376); the #372 preload did not
drop a frame; WAYLAND_DEBUG printed nothing on this firmware.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
GLinnik21 added a commit that referenced this pull request Oct 2, 2026
A simplify pass over #376 and #377, with the review follow-ups from #376.

The background prewarm drain now runs only when the live drain leaves at least BACKGROUND_MIN_US
(1 ms) of the 2.5 ms budget, so a sliver does not buy a whole parked string; a host test covers the
sliver and the empty-live-queue case. Stale "one string a frame" and "six-millisecond" comments in
text.rs and track_menu.rs describe the time-budgeted drain.

tv-sched-trace.sh defaults to --secs 6 (the measured loss-free length on the 4.4.84 kernel), its
usage() prints the usage line, and the ring sizing names its event rate and size. Its test has one
env builder, one clock constant and one ps per pid. docs/player-submenus.md agrees on the default
and records the measured effect of #376.

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