Repository navigation
gfx: arm the post-120-present EGL_BUFFER_AGE probe only on a dev trigger - #980
Merged
Merged
Conversation
plx_gfx::egl::late_probe() ran after every SDL_GL_SwapWindow in every build, stable included. At present 120 it issues a one-shot eglQuerySurface(EGL_BUFFER_AGE) and logs "egl surface (after 120 presents)". On the Mali-T820 dev TV that query blocks the swap 13-16 ms, about 2 s after every launch: one visibly dropped frame per launch, and the cycle-1 miss in the hero-pong / grid-pong fps benches. Measured on the device 2026-10-24: 15 of 15 baseline bench runs had one 13-16 ms swap on the frame right after that log line, and every cycle 1 missed 1-2 refreshes. With the query compiled out, 0 of 3 runs had it. A same-tree on/off pair agreed: 15.9 ms swap block in cycle 1 at baseline, none with the query removed. The line is diagnostic only (docs/egl-partial-update-and-damage.md and docs/webos10-lab-report.md cite it), so the probe stays, opt-in: it is armed by /tmp/plxnative-eglage, read ONCE at the boot-time EGL probe. Unarmed, the handles are never remembered, so late_probe() stays on its null-handle return (one load and a branch per present). Nothing in tests/, ci/ or tools/ parses the line. The damage experiment (egldamage) used to share the late probe's handles, so arming it alone would have re-armed the blocking query. It now holds its own (DMG_DPY / DMG_SURFACE); frame_damage() makes the same calls as before. eglage is registered in dev.rs's DIAG list: it only observes, so arming it must not suppress the who's-watching picker and move a measurement boot off the screen it measures. Regression test first: the_late_probe_is_off_without_its_trigger failed against the previous behaviour (handles remembered with no trigger), and passes with the gate; the_eglage_trigger_arms_the_late_probe holds the armed side. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review fixes for the opt-in `eglage` late probe; comments and docs only. - webos10-lab-report: the lab set ran the debug flavour and no /tmp trigger can be armed on a lab set (lab-diagnostics.md), so a lab boot no longer records the buffer_age-after-120-presents row. It can be re-measured only where a trigger can be armed (the dev TV), or by a lab-config switch that does not exist today. - egl-partial-update-and-damage section 7: arm the trigger under the install's runtime root (`make -s print-rundir`), not the bare /tmp that is only the stable install's root. Section 1b and the buffer_age bullet use the same wording. - egl-partial-update-and-damage section 1b: "everything above it is logged at every boot" was false; the `egl preserve:` and `egl damage:` lines need the `eglprobe` trigger. - dev.rs: `eglage` is not a pure observer. DIAG membership means it leaves the screen alone; it still costs one blocked 13-16 ms swap at present 120, so never arm it for a smoothness run. - egl.rs module doc: there are three exceptions to "boot only", not two; `frame_damage` runs every presented frame while `egldamage` is armed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
GLinnik21
marked this pull request as ready for review
October 24, 2026 10:27
GLinnik21
added a commit
that referenced
this pull request
Oct 24, 2026
…s steps run in order Reading the PR against main after #980: - Bullet (a) said every run's cycle 1 has a 13-16 ms swap from plx_gfx::egl::late_probe(). Since #980 that EGL_BUFFER_AGE query runs only with the eglage dev trigger armed, so an unarmed run has neither the stall nor the "egl surface (after 120 presents)" line. (a) now says a build from before #980 had the block, that a current build has it only armed, and that a cycle-1 miss on an unarmed build is something else (a first-time upload, prepare= with a large px=; first-time text raster, textx4). No other claim in the diff names that probe: the "probe kick" and "ground probe" mentions are the glass ground-probe readback, a different mechanism. - The debugfs steps are one runnable sequence: mount only if /proc/mounts does not list it and remember whether this run did, one-shot read, the 10 Hz sampler started in the background writing to an absolute /tmp path with its pid recorded, stop by killing that pid, unmount only if this run mounted it. The old block mounted, read and unmounted; the loop after it read the unmounted node, ran in the foreground forever, wrote to a relative `log` and had no stop step. Checked under dash (strict POSIX) with stubbed mount/umount/usleep, both as one shell and as one shell per step; not run on busybox or the TV. - "Roughly doubles" rested on one run (22 misses against 9); it now says so. - The "control spread 7-14" in bullet (b) is now 7-15 and names its sources: hero-pong 14, 7, 9 and grid-pong 15, 11, 9 (#980's device runs, 2026-10-24), and grid-pong 8, 9, 13, 14 (the controls above). Co-Authored-By: Claude Opus 5.5 <[email protected]>
GLinnik21
added a commit
that referenced
this pull request
Oct 24, 2026
…facts (#967) ## Summary Adds a `## Mali T820 facts for reading the counters` section to `.agents/skills/profile-tv/SKILL.md` (just before `## What counts as verification`) and annotates the older prose that the same facts contradict. Four docs files get a dated parenthetical; nothing else is rewritten. Docs only, no device touched, no code changed. ### The new skill section - **GPU clock fixed at 672 MHz, no GPU DVFS.** From the TV's own `mali_kbase.ko` (Midgard r12p0): the `kbase_platform_device_probe` frequency limits, the clock/regulator/OPP/devfreq imports it does and does not have, `dvfs_callback` -> `kbase_pm_get_dvfs_action`, and the kernel clock tree. It also gives the `GPU_ACTIVE` cycles-to-time conversion (one 60 Hz refresh is about 11.2M cycles, shared with the compositor). - **Driver GPU busy %, without HWCNT's `glFinish` serialization.** From the Mali debugfs `gpu_utilization` node, checked against a Home grid-pong control run and HWCNT. The steps are one runnable sequence for the TV's busybox `sh`: mount debugfs only if `/proc/mounts` does not list it (and remember whether this run did), one-shot read, a 10 Hz sampler started in the background writing to an absolute `/tmp` path with its pid recorded, stop by killing that pid, and unmount only if this run mounted it. It follows the mount-if-absent / pid-file idiom of `tools/tv-sched-trace.sh`. I ran it under `dash` (strict POSIX) with stubbed `mount`/`umount`/`usleep`, as one shell and as one shell per step, in both the unmounted and the already-mounted case; it was not run on busybox or the TV. The section keeps the warning that the sampler disturbs the bench: in one run (22 misses against 9 for the same control without it) it roughly doubled them, so misses are never graded from a sampled run. - **CPU and thermal.** From LG's power manager files under `/proc/lg/pm/` and the Glasshouse dashboard's `/api/stats` on the TV's port 8080, plus a control run at a flat 39-42 °C with the CPU pinned at its maximum. - **Reading `plxnative-herobench` misses.** From the HWCNT and `plxnative-drawmask` runs of 2026-10-24 on Home `hero-pong` and `grid-pong`: - (a) the cycle-1 13-16 ms `swap` is the one-shot `EGL_BUFFER_AGE` query in `plx_gfx::egl::late_probe()`. Since #980 that query runs only with the `eglage` dev trigger armed, so the section says a build from before #980 had the block on every launch, a current build has it only armed, and a cycle-1 miss on an unarmed build is something else (a first-time upload, `prepare=` with a large `px=`; first-time text raster, `textx4`); - (b) the miss rate above about 8M `GPU_ACTIVE` per frame, with the control spread in cycles 2-60 given as 7-15 and its sources named (`hero-pong` 14, 7, 9 and `grid-pong` 15, 11, 9 from #980's device runs; `grid-pong` 8, 9, 13, 14 from the controls in the section); - (c) the `glass` mask also skipping the glass source pass; - (d) the bimodal Home p95 from the ground probe's 1-in-30 kick frame (the glass ground-probe readback, not the EGL probe). - **Home pong census.** From the same release-build drawmask runs: `GPU_ACTIVE` saved per frame by removing one draw class. The section points at `docs/backdrop-blur-profiling.md` for `plxnative-drawmask` usage instead of restating it. Every repo identifier it cites (`late_probe` in `rust-modules/gfx/src/egl.rs`, the `egl surface (after 120 presents)` log line, `plxnative-drawmask` with `all`/`glass`/comma lists, `plxnative-herobench`, `hero-pong`/`grid-pong`) was grepped on `origin/main`. ### The older prose that is annotated Each is a dated "(2026-10-24: ...)" parenthetical beside the sentence it corrects, pointing at the new section; the original sentence stays so the record of what was believed is kept: - `docs/backdrop-blur-profiling.md`: "no GPU clock node anywhere", the "GPU DVFS / clock scaling" explanations for the source pass, the Detail frame misses and the Home capture stall (six places). - `docs/glass-hardware-budget.md`: "no temperature sensor and no GPU clock at all" and the "cold television" limitation. - `docs/perf-view-buffers-and-thermal.md`: the "exposes no temperature sensor and no GPU clock" quote and the suggestion to build a thermometer probe. - `tests/README.md`: the thermal-hypothesis note (a temperature can be read after all, from LG's power manager). No linked issue: findings from a Home pong frame-drop investigation. ## Verification Docs only, so no `make check` (CI gates it). On the committed tree, with `git status --short` empty after: - `python3 ci/check-placeholders.py`: `check-placeholders: ok (38 references: 23 counted, 15 exempt with a reason)` - `python3 ci/test_ci_workflows.py`: `Ran 77 tests in 3.076s` / `OK` - `python3 ci/test_source_bundle.py`: `Ran 43 tests in 4.519s` / `OK` - `python3 .claude/hooks/outbound-guard-test.py`: `outbound-guard: 68/68 checks correct` No device was touched. The measured numbers are the ones from the 2026-10-24 investigation and #980's device runs, and were not re-measured for this PR. Co-Authored-By: Claude Opus 5.5 <[email protected]>
GLinnik21
added a commit
that referenced
this pull request
Oct 24, 2026
) ## What and why `fs_img.frag` (the image program, `IPROG`) has an early exit for any draw that is not a rounded card: `u_card.z < 0.5` writes `vec4(tex*u_tint.rgb, ta*u_tint.a)`, about 2 arithmetic words and 1 texture word a fragment. Midgard sizes registers and occupancy for the whole shader, so that exit was charged the card chain's footprint it never runs. The two Home hero photographs (radius 0) take it over about 2.1M px a frame, and so does every resting card's interior piece (`card_cut` splits it off with the card flag off). Measured on the device 2026-10-24. This adds `fs_tex.frag`, that exit as a whole program, linked with the unchanged `vs_img.vert`. - Body: the same declarations at the same precision and the same three statements as the exit. It reads `u_tex`, `v_cuv` and `u_tint` and nothing else (no premultiply, scrim, crop clamp or colour-space flag stands behind that exit), so nothing had to be carried over or excluded. - Routing, in `draw_tex_core_in`, by the pure `plain_texture_program(plain, overridden, radius)`: a draw goes to the new program when it carries no focus/still program override and `radius < 0.5` (the packed `u_card.z`). A rim, shadow pad or tint do not matter: the shader never reads them past that exit, so a radius-0 `Class::Card` hero with a shadow pad routes there too. A split card's interior piece (drawn last, radius 0) routes there as well; its four ring pieces stay on `IPROG`. A still-program card's interior stays on the still program (its exit is `stillOver`, not the plain write). - The program is optional like `FOCUS_IMAGE`: if it does not link, `IPROG` draws the same picture as before and a line is logged. - Every uniform it reads (`u_trect`, `u_uvrect`, `u_tint`) is sent on every bind from one helper; `u_tscreen` and the sampler unit are set once at link. - The overdraw/drawmask ledger is untouched: `gate()` still runs first, `note_card_path` still books the same paths. The program is chosen after both. Expected saving (an ESTIMATE, not a result): 0.5-1.0M GPU cycles a frame on hero-pong and 0.2-0.4M on grid-pong. ## Identity evidence (macOS simulator, raw 3840x2160 PNGs) Captured with `tools/screenshots.py --keep` on `home`, `home-shelves`, `library-grid` (the demo library), comparing the raw `shot.png` the sim writes, before JPEG encoding. A canary build (the new program halving its colour) changed 7.6M of `home`'s 8.3M pixels, so these scenes do run through the new program for most of the page. Desktop GL ignores precision qualifiers, so this proves the routing and the arithmetic, not Mali's fp16 rounding; that rests on the identical declarations the new test pins. Run-to-run noise on `origin/main` (20 `home` captures of `origin/main`, one of them the reference): `home` differs by 0 to 2880 px (max channel delta 1, or 2 in 98 px), `home-shelves` by 0 to 2 px, `library-grid` by 0. Branch vs main: - `library-grid`: 0 differing pixels in every run. - `home-shelves`: 0 to 2 px in all runs but one (below). - `home`: in 17 of 19 branch captures, 0 to 3445 px against the main reference, max delta 1 or 2, in the same bottom-left region the main-vs-main noise sits in (identical bounding box (222,1425)-(790,1559) for branch-vs-main and main-vs-main). Three of them were pixel-identical to the main reference or within 4 px. - Two of the 19 branch `home` captures (the first one after building, and one more) showed a different pattern: about 10-11k px, max delta 1-2, scattered over the hero photograph region. Neither reproduced in 17 further branch captures (home-only and full runs), and none of the 20 `origin/main` captures showed it. I could not tie it to the change: the new program's output is a pure function of its inputs and 17 captures match, which points at a differing input (an animation caught at a slightly different value under load, the failure mode `tools/screenshots.py` itself documents) rather than the program, but that is an inference, not a measurement. It is the one thing the reviewer should weigh. ## Local tests - `make test-crate C=plx_gfx T=plain`: `test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 157 filtered out` - `make test-crate C=plx_gfx`: `test result: ok. 163 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out` - Mutation check: changing `fs_tex.frag`'s alpha term, or the rule to `radius < 0.6`, fails 3 of the new tests. - The release-config hook's `cargo check --lib --no-default-features` stayed silent after the last edit. `make check` was not run locally (congested machine); CI gates it. ## Device measurement Measured on the dev TV (Mali-T820, webOS 4.5) on 2026-10-24: - **Build:** `make ARM_PROFILE=release deploy` of 6bea562. - **Runner:** `tests/run.py --fps --mock`, panel off, no sampler. - **Control:** the same base plus #980. - **GPU counters:** `plxnative-hwcnt=frame.ui`, GPU_ACTIVE per frame, first 60 frames discarded. - **Misses:** from separate runs with no counters. | scene | build | GPU_ACTIVE p50 | p95 | missed, cycles 2-60 | |---|---|---|---|---| | hero-pong | control | 10.27M | 11.86M | 14, 7, 9 | | hero-pong | this PR | **9.16M (-1.11M)** | 10.96M | 12, 5, 5 | | grid-pong | control | 9.93M | 11.54M | 15, 11, 9 | | grid-pong | this PR | 9.80M (-0.13M) | 11.41M | 14, 14, 12 | - **Hero** gained more than the estimate. - **Grid** gained less: its resting card interiors are a small share of the frame. - **Grid misses** are unchanged within run-to-run noise, since 9.8M is still well above the ~8M knee where misses fall off. - **Not yet done:** a pixel diff of this build on the device. No linked issue. TV pixel check (2026-10-24, release build of main + this + #985, UI-plane GRAPHIC capture on the mock catalog, the TV's own OSD masked): Home with the hero is 0 px different from the pre-work build (3e6665a); on the Home shelves and the library grid the only differing pixels (1118 and 20, each 1/255 in red) sit in the card shadow pad, which only #985 touches. Nothing this change draws differs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
plx_gfx::egl::late_probe()(rust-modules/gfx/src/egl.rs) was called unconditionally after everySDL_GL_SwapWindow(app/run.rs), in every build, stable included. At present 120 it issued a one-shoteglQuerySurface(EGL_BUFFER_AGE)and loggedegl surface (after 120 presents): buffer_age=… ok=… err=….On the Mali-T820 dev TV that query blocks the swap 13-16 ms, about 2 s after every launch: one visibly dropped frame per launch, and the cause of the cycle-1 miss in the
hero-pong/grid-pongfps benches.Evidence (device, 2026-10-24)
swapon the frame right after that log line, and every cycle 1 missed 1-2 refreshes.The fix
The line is diagnostic only, and
docs/egl-partial-update-and-damage.mdanddocs/webos10-lab-report.mdcite it, so the probe stays reachable as a dev diagnostic. It is now opt-in:remember_late_handles()(called once from the boot-timeegl::probe()) readsdevtrig::flag("eglage")and only then remembers the display and surface. Unarmed, the handles stay null andlate_probe()stays on its first-branch return: one load and a branch per present, in every build. The trigger is read once, at boot, never per frame. A release build cannot arm it (devtrig::flagisfalsethere).eglageis registered indev.rs'sDIAGlist ([&str; 41]to42). It is a pure observer, likeframedropandframecb, so arming it must not suppress the who's-watching picker and move a measurement boot off the screen it measures.eglprobeandegldamageare not inDIAGbecause they mutate the surface or the picture.egldamageexperiment used to share the late probe's handles (LATE_DPY/LATE_SURFACE), so arming it alone would have re-armed the blocking query. It now holds its own (DMG_DPY/DMG_SURFACE).frame_damage()makes exactly the same calls as before, through its own statics; its buffer-age query is untouched.egl.rsmodule doc,late_probe, theprobe()call site, therun.rscall site,docs/egl-partial-update-and-damage.md(note under the boot log block, thebuffer_agebullet, and the section 7 recipe) anddocs/webos10-lab-report.md(note under the 6.1 table). Each carries a dated note: off by default because the query blocks a swap 13-16 ms on the T820.tests/,ci/ortools/parses theegl surface (after 120 presents)line (grepped). Thetests/manifest.jsoncomments forhero-pong/grid-pongquote a dated 2026-10-08 baseline (10-12 missed per 60 cycles) that includes this one cycle-1 miss; it is a dated measurement and thebench_missed_max: 0grading is unchanged, so I left it alone.How to arm it
The trigger is read once at boot, so arm it before launch. On the set,
$(make -s print-rundir)is the install's runtime root (the trackedFLAVOR=debugdefault is not bare/tmp; seedocs/two-installs.md):Then
grep 'egl surface (after 120 presents)'in the event log. Do not leave it armed for a smoothness or fps run: that is the 13-16 ms swap block.Test (red, then green)
the_late_probe_is_off_without_its_triggerfailed against the previous behaviour (the handles were remembered with no trigger armed):panicked at gfx/src/egl.rs:892:13: the late probe remembered EGL's handles with no trigger armed,test result: FAILED. 1 passed; 1 failed.test result: ok. 2 passed; 0 failed(make test-crate C=plx_gfx T=late_probe).the_eglage_trigger_arms_the_late_probeholds the armed side; mutating the gate (inverting it) failed both tests, so neither is vacuous underdevtriggers.late_probe()with a fake handle, so it cannot reach a real EGL entry point on a Linux CI host.Gates (on the committed tree,
git status --shortempty before and after)Host
python3here is 3.9 (notomllib), so the firstmake checkfailed inci/check-rust-inputs.pyand its test: environmental, unrelated to the diff. The re-run, andmake check-nodefandmake, had the uv-managed Python 3.12 first onPATH.make check: exit 0.==== check: 106 steps — all ok (321s wall, 394s cpu, 4 at once …) ====,==== check: cargo — ok (872s) ====,==== check: python — ok (657s) ====,==== check: harness — ok (656s) ====.plx_gfx:test result: ok. 161 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out.plxnative_modules:test result: ok. 936 passed; 0 failedandtest result: ok. 1049 passed; 0 failed.make check-nodef: exit 0,Finished \dev` profile [unoptimized + debuginfo] target(s) in 40.45s`.make(ARM cross-build): exit 0,Finished \tvdev` profile [optimized] target(s) in 4m 11s, then theplxnative-storage` helper linked and staged.fw-compat-revieweris not needed: there is no newextern,dlsymtarget,#[link]orDT_NEEDEDchange; the probe still resolves through the existingresolve().Device verification
Measured on the dev TV (Mali-T820, webOS 4.5),
make ARM_PROFILE=release deployof 31f74a3 (the later head only changes comments and docs),tests/run.py --fps --mockwith the panel off and no sampler, 2026-10-24.egl surface (after 120 presents)linesprepare=15.0; swap 0.4 ms)swapon the frame after the probe's log line, and every cycle 1 missed 1-2 refreshes.No linked issue.
🤖 Generated with Claude Code