Repository navigation
Scene: keep per-output visibility across paints (#388) - #394
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…putation order (review r1) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mmitInFlight pre-walk, full audit compare (review r2) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…g/wlroots model) instead of a keyed walk cache Part 2 rewritten: keep only per-output geometry (nodes, pieces, occlusion), read the sampled view and extent live, invalidate on structural change. Part 1 also moves software-cursor motion to wake_for_cursor_damage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…full SceneBuild audit, storage invariants (review r3) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…y counters, unresolved source, test 2 mutations (review r4) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Test 4 exports the NameWindowPixmap backing, not the window XID; diagnosis states inclusive/self and what the window-map count proves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lidated visibility) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Plan 1: counters task first and builds_per_output defined once on them; ticks through Backend::maybe_composite; real lvp-env file chained with && and a SKIP recording_scene check; one site test per draw.rs line anchor; reachable mutations for the spanning, no-pieces and write-nothing cases; WalkCause pub in telemetry.rs; fixed-size per-output telemetry storage; dormancy test accessor. Plan 2: tests observe through test-only SceneBuildObservation / SceneBuildProbe built in yserver-render (SceneBuild and scene_build_diff stay crate-private) and the build each tick used; store tests on the Vulkan fixture with unmasked mutations; in-place content offset path; partially covered window for HiddenDamage; DRI3 order, narrow skip and coordinator hardware runs; BuildKind pub(crate) in telemetry.rs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Plan 1: the no-pieces test reaches an armed off-output window by moving it off after a settle (a no-background map still records damage); site tests use the for_tests_scene_wants_compose wrapper. Plan 2: re-export the for_tests observation types; the redirected-resize mutation removes topology and window generation; the DRI3 hardware mutation run is flagged as undefined behaviour in the consent request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… settle (review r3) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
walk_needed now returns the first true input as a WalkCause, and every scene build on an output is counted by its cause in the telemetry bucket and lifetime view. The scene telemetry line reports the per-output counts. Adds the two-output paint fixture used by the paint-wake tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Implemented-By: Claude Haiku 5.5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Implemented-By: Claude Haiku 5.5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Implemented-By: Claude Haiku 5.5
…llscreen_direct_scanout_without_unflip Sibling tests reset scanout_m0.interval_start before observing a candidate. This one did not, so under CPU load the observation ran more than one second after backend creation and the M1 probe reset m1_probe_reject, failing the assertion. Test-only; no production change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Implemented-By: Claude Haiku 5.5
…round (joske#388) Moves five backend paint sites from wake_for_damage to wake_for_paint: the tiled and solid border rings (paint_window_border_within), the root background pixel and pixmap setters, and the root-scanout copy (try_copy_area_root_scanout). Each write they make is recorded through DrawableStore::damage, and none changes a walk input. Adds paint_wake tests for each site, plus a border count test and clipped_paint_leaves_the_scene_quiet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Implemented-By: Claude Haiku 5.5
A tick skipped for an in-flight cursor commit returns before build_scene, so it is a pre-walk skip like PendingAcks. Counting it as a walk made the dormancy reconcile run on a tick that built nothing, which put a paint's window to sleep on the output still waiting for its cursor commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Implemented-By: Claude Haiku 5.5
…an fail Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
) The store's topology_generation bumped on every pixmap allocation and free. Visibility never reads pixmap bindings, so pixmap churn now leaves it unchanged: allocate, detach, rebind, decref and destroy bump only for a Window or Root binding. set_content_offset bumps when the stored offset changes, for any drawable kind. set_scene_participating and set_redirected_target keep their bumps. SceneInput gains windows_generation and shape_generation, the two generations the kept visibility state is validated against. scene_input fills them from TrackedWindows::generation and the backend's shape_generation at every call site. Tests in tests/scene_validation.rs pin the narrowed rule (pixmap churn, window binding changes, content offset) and that every shape writer moves shape_generation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Implemented-By: Claude Haiku 5.5
…oske#388) node_pieces computes a node's visible pieces per place rect in emission order. emit_with_pieces runs the per-tick half on those pieces: draws, signature, sampled and pieces ids, damage and the snapshot. It reads the source's sample view and, under On, its storage extent live from the store. Under Off the caller's denominators are kept, so Off output is unchanged. emit_node composes the two and returns None when the source does not resolve or has a null image view. Its callers push no presence then. Adds split_emit_matches_full_walk_bit_for_bit, a digest of the e16-like walk in both modes, pinned from the code before the split. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Implemented-By: Claude Haiku 5.5
…ucture (joske#388) Each output keeps the geometry of its last On walk: every node that reached emit_node, in computation order, with its visible pieces per place rect, and the walk's structural counters. A tick whose validation inputs are unchanged (windows and shape generations, the narrowed store topology generation, the top-level order, the output layout and cow_host_xid) replays that geometry through the per-tick half of emission. Draws, damage, sampled views and extents are read live on every tick; the kept state holds none of them. emit_node is split into node_pieces (geometry) and emit_with_pieces (per-tick), and both paths run the same code in the same order. A kept node whose source no longer resolves falls back to a full walk on the same tick. Telemetry adds scene_full_walks/s and scene_valid_ticks/s per output. Implemented-By: Claude Haiku 5.5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- covered-paint test: after the cover moves, check that U is undormant and that its presentation damage composed (the pending check hides dormant drawables, so this is checked directly). - DRI3 test: ignore reason names the real requirement; check that the redirect and naming tick is a full walk. - cursor test: the deferred Present is stood in for by its copy and mark_dirty; comment corrected. - RootNode denominator doc: read under Off only. - scene_build_pair_for_tests: builds on a copy, so the kept state is left as it was even when the replay falls back. Implemented-By: Claude Haiku 5.5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ke#388) Table-driven: each structural family (position, restack, shape, redirect, unredirect, participation, in-place content offset, map, unmap, destroy, redirected resize, COW, root resize, output layout) takes one valid tick, the change, and one full walk, then matches a fresh walk and walks valid on the next unchanged tick. Each row names the input its mutation removes; the root and output-layout rows are carried elsewhere (replay source fallback, sync layout reset), noted in the test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Implemented-By: Claude Haiku 5.5
Drop the sync_output_layouts kept reset: the OutputLayout comparison in KeptVisibility::matches covers every layout change it guarded (root_rect, mode, transform), so the reset is redundant. Test-only: SceneBuildObservation records the carried damage count. Scene validation: the per-CRTC same-size modeset rebuilds output 0 and pins it; the root row pins the Root rebind with the replay guard; the other-output row asserts output 0 queued no flip and carried nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Implemented-By: Claude Haiku 5.5
…joske#388) Under the damage audit, every valid tick is compared with a fresh On walk over the same live state. A difference is logged and counted, the full walk's result is used, and the kept geometry is replaced. A kept source that no longer resolves is counted and walks in full on the same tick. scene_build_diff is no longer test-only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Implemented-By: Claude Haiku 5.5
scene_build_diff lived in scene/for_tests.rs, whose SceneBuild import is test-support only, so a plain `cargo build --bin yserver` failed. It is the audit's production comparison: move it next to note_validation_mismatch in damage_audit.rs. The yserver backend's two accessors over test-support observation types are #[cfg(test)]. Every gate step built with test-support unified through the dev-dependency, so the gate now also builds the binary on its own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, not borrows Hardware smoke found kept visibility invalidated on almost every tick: xterm's no-op ChangeWindowAttributes bumps TrackedWindows on each borrow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rrows Hardware smoke (AMD, xfwm4, two xterms, YSERVER_LOOP_TELEMETRY=1): about 50 full_walks/s against 0-5 valid_ticks/s. xterm rewrites CWBackPixel with the value it already has ~160 times/s, and every mutable borrow of the window map bumped the generation, so each paint invalidated kept visibility. TrackedWindows now compares the map with a snapshot on the first read after a borrow and bumps only when its contents differ. The spec's Part 2 described the generation as bumped by every mutable borrow; this commit makes it a content mark, as that section intends. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Implemented-By: Claude Haiku 5.5
Test (b) pins the move + no-op outcome only; the move's dispatch already resolves the generation, so the per-borrow snapshot mutation is caught by no_op_rewrite_does_not_hide_an_earlier_background_change. Plan erratum. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, this looks right. We went through everything the walk reads and found nothing the validity key misses, and the 11 converted paint sites all look correct. We'd like Samueru's measurement before merging, since #388 is his report. A few things in the meantime:
|
|
Hardware idle test of this PR against its own base, same machine and desktop. Setup. RX 580 (RADV), 3 outputs at 1440x900 ~79 Hz, i3 + polybar + fastcompmgr + wallpaper, no browser, one idle terminal. Base is master
(% of one core.) Frame presents and PR counters at idle, both windows: Limits. One server session per side, the PR measured first, not interleaved. Within a session the two windows agree to 0.2 points, but I haven't bounded session-to-session variance, so treat the 0.6 points as indicative. The RADV workaround is on both sides, so the absolute numbers are not stock upstream. The base build has no walk counters, so I can't give its walk rate. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eneration Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Implemented-By: Claude Haiku 5.5
…op the digest test Joske's review items 2 and 3 on PR joske#394. - Drop the pre-split digest test (split_emit_matches_full_walk_bit_for_bit) and walk_needed_for_each_input_alone_and_not_otherwise; the exhaustive walk_needed_reports_the_first_true_input and the existing walk tests keep the mutations they killed. - scene_validation: one table test each_non_structural_change_keeps_visibility_valid absorbs the paint, pixmap churn, unread-field, cursor and present rows. Shape-only and topology-only helpers that no other test used are gone. Restored: window_binding_changes_move_topology and content_offset_change_moves_topology, which no other test kills. - paint_wake: one table test each_paint_site_is_scheduled_by_its_own_damage replaces the 11 per-site tests and the clipped-paint test. The routing tests fold into the table and copy_area_on_one_output_builds_only_that_output. - Shared helpers (u32s, tick, copy_area_at) live once in paint_wake.rs. No production code changes. Implemented-By: Claude Haiku 5.5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…elpers (review) Fix round 1 for the review of 1789d6c. - Topology: check_family asserts the topology generation moves for every row whose mutation names topology. The map, destroy, COW and in-place content offset rows now carry the topology checks, so window_binding_changes_move_topology and content_offset_change_moves_topology are removed. - Projected-change witness becomes a families row (plan 3 M5). - paint_wake and scene_validation share one request layer: Le body builder, req, create_window, configure, change_gc, composite-style helpers, settle_clean. The fixture helpers return a cleanup guard, so fixtures finish on drop. - fixture_settles_with_nothing_pending removed: settle and the routing rows cover its checks. - define_root_argb_cursor uses cursor_support::create_argb_cursor; the power executor and output lookup reuse per_crtc_config. - One assert_kept_matches_fresh helper for the valid-equals-fresh checks. No production code changes. Implemented-By: Claude Haiku 5.5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…pology bump Also name the subwindow clip cache as a reader of the tracked projection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for going through it. All four items are addressed; new commits on top, nothing rewritten.
|
Part of #388 (idle CPU). Replaces #391.
The scene redid its visibility work — which windows show on each output, their visible pieces, what covers them — on every tick, for every output, even when only damage changed. In Samueru's profile
visit_window_subtreewas 8.9% of samples (inclusive) andchildren_index4.75%; #391's counters saw 22,830 builds in 60 s with an unchanged window tree.This follows Xorg's model: visibility is recomputed when the tree changes (where
ValidateTreewould run), not on paint. The per-tick half (draws, damage) is split from the geometry half as in the wlroots scene graph.Change
1. Paint wake. A protocol paint (CopyArea, PutImage, border paints, root background, root-scanout copy — 11 sites) now calls
wake_for_paintinstead ofwake_for_damage. It schedules only the outputs where the painted drawable has pieces (via the store's existing pending-presentation damage) and no longer raisesscene_structure_dirty, which forced a walk on every output. Structural callers keepwake_for_damage. WithYSERVER_DAMAGE_AUDIT=1paints still raise structure, so the audit keeps comparing every output. A tick that only commits an in-flight cursor (CursorCommitInFlight) no longer counts as a walk (TickOutcome::walked()).2. Kept visibility per output. Each output keeps the geometry of its last walk: every node that reached
emit_node, in computation order, with its visible pieces, plus the inputs that walk saw. It holds no image view, extent, draw or damage — those are read live every tick, so a DRI3 promotion or a backing swap is picked up without a counter.emit_nodeis split into a geometry half and a per-tick half that runs identically on fresh and on kept pieces.A tick replays the kept geometry when all of these are unchanged, and walks in full otherwise:
TrackedWindows::generation()DrawableStore::topology_generation(), narrowed to Window/Root bindings, participation, redirect target and content offset (pixmap churn no longer moves it)OutputLayout, andcow_host_xidA kept source that no longer resolves falls back to a full walk on the same tick. Under
YSERVER_DAMAGE_AUDIT=1(existing flag) every valid tick is also compared field by field with a fresh walk; a mismatch logsdamage-audit validation-mismatch output=N field=<name>and the tick uses the fresh result.3. The windows generation counts changes its readers can see.
TrackedWindowsbumped on everyDerefMut. On real hardware xterm sendsChangeWindowAttributes(CWBackPixel)with the value the window already has before each clear (~160/s with two busy xterms), so kept visibility was invalidated on almost every tick.DerefMutnow only marks the map possibly changed. On the next read,generation()compares a per-windowTrackedGeometryprojection with a snapshot, and bumps only if it differs. The projection holds exactly the fields that the walk or the subwindow clip cache reads:x, y, width, height, depth, mapped, parent, stack_rank, border_width, viewable. Cursor, background and border-colour changes (GTK'sDefineCursoron hover) leave it unchanged. Equal values mean equal projected contents; the converse does not hold. Every reader keeps its call, and no mutation site changes.Nothing client-visible changes: exposures,
ClipNotify, clip lists and composed pixels are the same.Telemetry (
YSERVER_LOOP_TELEMETRY=1):walk_cause/s[outN[structure= presentation= first_frame= owed= pending_structure= audit=]],scene_full_walks/s[outN=],scene_valid_ticks/s[outN=].Numbers
Release bench (
tick_build_bench, thewalk_benche16-like fixture at 2560×1440, root + 10 shaped top-levels × 6 children, best of 5): valid tick 65.9 µs vs full walk 219.7 µs (~3.3×).Real KMS, xfwm4 + two xterms running
yesandtop, 1920×1080, one output:Dragging a window (≈530 moves in 10 s) walks in full as expected (~55/s, 17–22 µs per build). 15 s of pointer motion over the windows: 0 full walks, 26–48 valid ticks/s, no cursor
EBUSY. Screenshots clean on both GPUs.Samueru's idle measurement (RX 580, 3 outputs at 1440×900, i3 + polybar + fastcompmgr, against base
3e09d8a9; #394 (comment)): master 7.83% / 7.73% CPU, this PR (87d1a690) 7.17% / 7.17%, with the same presents andqueue_submit2/s. That is ~0.6 points, ~8%. At idle,scene_full_walks/sis 0 on all three outputs andscene_valid_ticks/sis 107–116 per output.This removes the scene-walk share of the profile only; the submit count discussed in #388 (
redirect_iso, the flush before each DamageNotify) is untouched.Tests
Backend tests on lavapipe go through
dispatch_raw,maybe_compositeandon_host_input. Each fails under a named mutation.paint_wake.rs:presentation.scene_validation.rs:each_non_structural_change_keeps_visibility_validchecks each row against a fresh build. Rows: paint, pixmap churn, SW cursor motion, a deferred Present, and each unread window field (CWBackPixel,CWBackPixmap,CWBorderPixel,CWBorderPixmap,CWCursor).each_structural_change_walks_in_full, the families table, asserts a full walk and the moved mark for each row: configure, restack, a child restack followed by a no-op borrow, shape, redirect, unredirect, participation, in-place content offset, map, unmap, destroy, redirected resize, COW materialization, root resize, output layout.OtherOutputdamage works on a valid tick.walk_neededover all 64 input combinations.Also fixed in its own commit (
present_scanout::hidden_cursor_allows_fullscreen_direct_scanout_without_unflip, test-only): a pre-existing load flake — the test did not reset the probe interval like its siblings, soobserve_scanout_m0resetm1_probe_rejectafter 1 s under load.Gate: fmt, clippy (default, tcp-transport, xdmcp, windows, freebsd),
cargo build --bin yserveralone in debug and release, workspace tests, the workspace--ignoredlavapipe suite, the audit tests withYSERVER_DAMAGE_AUDIT=1, layout check,just man, and 5 loaded runs of the touched suites.🤖 Generated with Claude Code