Repository navigation
Conversation
ShojiWM gave every surface its dmabuf feedback on every frame, through smithay's send_dmabuf_feedback, which calls set_feedback. set_feedback compares the format tables whenever the feedback is another Arc, and keeps its old Arc when they are equal: given an equal feedback on every frame, it compared the tables on every frame, about a tenth of the compositor's CPU in a profile (bea4dev#185). The feedback chosen for a surface changes rarely: a trace of one session logged 97 changes. ShojiWM now walks the surfaces itself, as smithay does (the surface tree, then the popups), and keeps the feedback last sent in each surface's data map. set_feedback runs only when the chosen feedback differs from it; the kept one is then the chosen Arc, so the next frame's comparison stops at the pointer.
A surface on two outputs was sent each output's feedback in turn, so the kept feedback changed on every frame and the table comparison came back for it. It now gets its primary scan-out output's feedback only, the filter smithay's own walk applies.
This branch has not been deployed
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.
Fixes #185.
Problem
On every frame,
render_surfaceinbackend/tty.rsgives each window, layer surface and lock surface its dmabuf feedback through smithay'ssend_dmabuf_feedback, which callsSurfaceDmabufFeedbackState::set_feedback. When the new feedback is a differentArc,set_feedbackcompares the format tables, and keeps the oldArcif they are equal. So an equal feedback, given again on every frame, makes the tables compared on every frame. In the profile of #185, this took about a tenth of the compositor's CPU. The feedback chosen for a surface rarely changes: a trace of one session logged 97 changes.A second effect: the old calls passed
|_, _| Some(output.clone())as the primary-output function, so a surface on two outputs received each output's feedback in turn. Its kept feedback then changed on every frame, and the table comparison ran again for it.Fix
All in
src/shojiwm_lib/src/backend/tty.rs:send_dmabuf_feedback_treewalks a surface tree as smithay's own walk does. It skips surfaces whose primary scan-out output (surface_primary_scanout_output) is not the output being rendered, as smithay's filter does.SentDmabufFeedback).set_feedbackruns only when the chosen feedback differs from the kept one. The kept value is then the chosenArc, so the next frame's comparison stops at the pointer.send_dmabuf_feedback_with_popupswalks a root surface and then its popups, asWindow::send_dmabuf_feedbackandLayerSurface::send_dmabuf_feedbackdo.render_surfaceuses these for windows, mapped layer surfaces and the session lock surface. The selection (select_dmabuf_feedback, render or scan-out feedback) is unchanged.Tests
No test is added. No new measurement is included in this PR; the numbers above come from #185 and from the trace in the commit message.
cargo test --workspacepasses, except two tests that also fail on upstreammainin our environment:evaluator::tests::embedded_runtime_ipc_does_not_leak_fds_across_reloadsandinput_method_keyboard_grab_gets_the_keymap_of_the_keys_it_is_sent.This change has been running daily in the author's own session (a Windows-7-like desktop on ShojiWM).