Repository navigation
Scene: stop rebuilding outputs while another output waits for its flip - #395
Conversation
scene_structure_dirty was one flag for all outputs and was cleared only once every output had built. While one output waited for its page flip or a cursor commit, every loop iteration re-admitted the other outputs: they built, found no damage and skipped, until the flip retired. With two outputs on hardware that was 159 structure builds for 8 structure changes in one second. Each output now holds its own structure wake. A raise sets it on every output; an output consumes its own wake when it builds (Composed or EmptyDamage); pre-build skips and failures keep it. scene_structure_dirty now means "some output holds a wake". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The last direct write to scene_structure_dirty outside the tick raised the flag without an output wake; with no wake held it woke every output, and with one held it reached only that output. Wake the output whose cursor transition was deferred instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@Samueru-sama Could you test on this branch 🙏 |
|
Tested on real hardware: 3 outputs at 1440x900 (~79 Hz), i3 + polybar + fastcompmgr, one idle terminal. Base Method: 60 s idle, then 30 s with an override-redirect 300x200 window moved 60/40 px inside the left output at 12.5 moves/s. One session per side.
Presentation builds were unchanged: 44.7/s per output idle and about 49/s during the probe. The wake is consumed per output as intended: on this branch all outputs build at the same rate, while master builds the window's output more than the others. The saving here is only 5-6% of structure builds, and probe CPU is unchanged. The idle CPU difference is within the session-to-session spread I have seen on this machine (0.4-0.6 points), so I would not read it as a win. Likely reason: fastcompmgr keeps every output presenting, about 45 presentation builds/s per output, so each output has work regardless of its structure wake. The large reductions in the description come from a two-output Xfce desktop with the compositor off, where the non-moving outputs are otherwise idle. I have not tested compositor-off or direct scanout. The new |
|
Thanks, that's very useful. I've merged this as a targeted fix, since it removes the redundant rebuilds where outputs are otherwise idle, and #388 stays open for the rest. Your numbers raise two questions. If you have time for another round:
The counter sites plus a profile from the same interval should tell us where to spend the next round. |
|
Second round, same machine: 3 outputs at 1440x900, RADV patch and 1. Compositor off (fastcompmgr stopped after login),
Without the compositor the structure builds drop 12-21% per output (5-6% with it). CPU moves about 0.2 points, inside the 0.4-0.6 point session-to-session spread I have seen here. Composite submits are about 133/s idle and 148/s during the probe on both builds. Presentation builds in the probe are uneven in both: out0 about 15-19/s, the other two about 105-109/s. 2. Idle raises,
Same interval: composite submits 146/s, frame presents 146/s, paint submits 474/s, each output building 68 structure + 45 presentation per s. Profile from the same 60 s: 3175 samples, no single hot function. By DSO: The sites agree with your guess that the wake follows Present. I did not isolate the wallpaper from fastcompmgr, and the compositor-off runs used builds without the site counters. Direct scanout is untested. |
Part of #388 (idle and desktop CPU).
With two or more outputs, a single window change made the other outputs rebuild the scene over and over while one output waited for its page flip. The structure flag was shared by all outputs and cleared only once every output had built, so each loop iteration rebuilt the outputs that were already done, found nothing to draw, and skipped. On a two-output Xfce desktop with the compositor off, one output built 159 times in a second for 8 window changes and 11 frames.
Each output now keeps its own structure wake. A change sets it on every output, an output clears its own when it builds, and an output waiting for a flip or a cursor commit keeps its wake until it can build. A deferred cursor retry wakes only its own output. Single-output setups are not affected.
Measured
Two outputs at different resolutions, Xfce with the compositor off, same actions on master plus counters and on this branch:
During drag the remaining structure builds roughly match the real window changes. No visual differences.
Not fixed here: moving a window can still make one output rebuild for presentation damage while the other output waits for its flip. That is a separate follow-up.
Tests
structure_wake_is_consumed_per_output(paint_wake.rs): with output 0 waiting for a flip, a restack builds output 1 once; further ticks build nothing; output 0 builds after its flip retires; a second change builds output 1 once again. It fails on master at "further ticks build nothing". One tearing test now expects the paced output to keep its own cursor wake instead of clearing a shared flag.🤖 Generated with Claude Code