Skip to content

tv-sched-trace: bounded trace_pipe read-back, and what the 2026-10-02 back-buffer-wait capture showed - #377

Merged
GLinnik21 merged 2 commits into
mainfrom
fix/tv-sched-trace-readback
Oct 1, 2026
Merged

GLinnik21 merged 2 commits into
mainfrom
fix/tv-sched-trace-readback

Conversation

@GLinnik21

Copy link
Copy Markdown
Collaborator

What

The tool. The first run of tools/tv-sched-trace.sh on the television stalled in its read-back: it read the non-consuming trace file, which re-walks the ring on every read on the 4.4.84 kernel, so 3.3 s of data took about nine minutes. The ring had also overrun, a third of the events were arch-timer noise, and no syscall events were enabled for the analyser.

  • The read-back 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 and says how many seconds it covers.
  • Entries and overrun are printed per CPU before the drain.
  • The arch timer is filtered out of the irq events (string filter, falling back to irq numbers, which is what this kernel accepts).
  • The ring is sized for the capture length and capped at 32 MB.
  • --tid N enables raw_syscalls for that thread, so the analyser can see what the frame thread blocks in.
  • Restore clears all of it.
  • tools/test_tv_sched_trace.py drives the script against a fake tracefs and a fake tv-ssh, wired into make check-python.

The findings. docs/player-submenus.md replaces the "next TV session" plan with what the capture showed (build 6ee274c, guest profile, mock server, player with the track menu and sub-menu oscillator):

  • The GPU is idle during the long waits: GPU_ACTIVE is the same 6.6 M cycles in 20–24 ms frames as in 16–20 ms frames, against a ~10.6 M budget.
  • osd_irq fires every 8.33 ms. The frame thread blocks in poll inside its first framebuffer command, is woken just after an interrupt, and normally commits 4.3–5.1 ms before the next one. A commit after that interrupt costs the next frame a full extra 16.7 ms.
  • Of 31 steady-state waits of 18 ms or more, 29 followed an on-time commit: the compositor released the buffer a cycle late. Two followed a late commit, both from platform threads preempting the frame thread. Neither class is fixable in the app.
  • The app's own defect was the unbounded text prewarm drain, fixed separately in Bound the player's text prewarm drain by time, not string count #376.
  • The Simplify the menu-open frame and frame-probe code, and wire the underlay preload debounce #372 underlay preload ran once in prepare and did not drop a frame.
  • WAYLAND_DEBUG=client printed nothing on this firmware; the wldebug leg is a dead instrument there.

Verification

  • make check-python on the committed tree: analyze-sched-trace self-test: ok; Ran 4 tests in 12.520s / OK (the new suite); Ran 371 tests in 120.531s / OK. shellcheck and bash -n clean.
  • The fixed script ran on the television: an 8 s capture with --tid returned 433,702 events; only CPU 0 overran (5,644 of 166,017), which is why the doc recommends --secs 6.

No Rust or C changes.

🤖 Generated with Claude Code

GLinnik21 and others added 2 commits October 2, 2026 02:06
… size the ring, add --tid

The first TV run read the non-consuming `trace` file, which re-walks the ring on every read: after
nine minutes 85k of 868k buffered events had arrived. The ring had also overrun at 20 s (1.32 M
written, 868 k kept, CPU 0's early events gone), the events were a third 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 (the
timeout or ^C) asks the set to end the drain, keeps what arrived as a valid gzip, says how many
seconds it covers and exits 3 (130 on ^C). Entries/overrun are printed before the drain. The arch
timer is filtered out of irq_handler_entry/exit (string filter, falling back to /proc/interrupts
numbers). --secs defaults to 8 and the ring is sized for ~60k events/s capped at 32 MB across CPUs.
--tid N enables raw_syscalls filtered to that thread. Restore clears the filters, disables the
syscall events and kills any reader left on the set.

tools/test_tv_sched_trace.py drives the script against a fake tracefs (trace_pipe is a FIFO) and a
fake tv-ssh, and is wired into check-python.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… device facts

Replaces the "next TV session" framing of the three legs with the results: the GPU is idle during
the long waits, osd_irq paces commits at 8.33 ms, most long waits follow an on-time commit and are
the compositor's, the frame thread's preemption is small, the text prewarm drain was unbounded, the
#372 preload did not drop a frame, and the Wayland debug leg printed nothing on this firmware.
Corrects the open-frame figure quoted from before #372 and the claim that the probe's run-queue
field reads 0. tv-sched-trace.sh's header now states what was observed on the 4.4.84 kernel and
recommends --secs 6; no behaviour change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@GLinnik21
GLinnik21 merged commit 9f126dd into main Oct 1, 2026
11 checks passed
@GLinnik21
GLinnik21 deleted the fix/tv-sched-trace-readback branch October 1, 2026 23:31
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