cosmic-comp/src/wayland/protocols
Gavin John d4c5714c10 perf(toplevel_info): optimize send_toplevel_to_client
PR #1279 tried to throttle `send_toplevel_to_client`, which was rejected. This takes (what I think is) a better approach, and instead makes some optimizations. We delay grabbing the mutex until it's actually needed, and we also checks to see if the state actually needs to be resent. This resolves some lock contention, and also avoids having to generate the state in the first place. Since `wayland-rs` uses a single mutex to lock the entire state, this both massively reduces lock contention and avoids making (apparently quite a lot of) unnecessary computation.

I decided to give this one to AI since I'm a bit busy right now (although I am still manually writing the commit messages and descriptions). I think it generally did a pretty good job, although I did have to make a few manual tweaks. While I don't have any empirical data, cosmic-comp idle CPU has gone down from ~3% all-core to 0-0.5%, even stress testing it with far more windows open. I can't say it *liked* opening 30-some windows in 2 seconds, but after it finished opening them all, it was still buttery smooth. Overall very happy with the results.

Assisted-by: Claude:claude-4-opus
2026-06-16 18:09:28 +02:00
..
output_configuration chore: clippy 2026-03-18 18:19:03 +01:00
workspace chore: clippy 2026-03-18 18:19:03 +01:00
a11y.rs chore: clippy 2026-03-18 18:19:03 +01:00
corner_radius.rs chore: format for Rust 2024 2025-10-22 23:55:11 +02:00
drm.rs chore: format for Rust 2024 2025-10-22 23:55:11 +02:00
image_capture_source.rs chore: Update smithay with Dispatch2 2026-05-19 19:26:25 +02:00
mod.rs image-copy: Use abstraction that's now provided by Smithay 2026-02-05 02:01:14 +01:00
output_power.rs chore: clippy 2026-03-18 18:19:03 +01:00
overlap_notify.rs chore: Update smithay with Dispatch2 2026-05-19 19:26:25 +02:00
toplevel_info.rs perf(toplevel_info): optimize send_toplevel_to_client 2026-06-16 18:09:28 +02:00
toplevel_management.rs chore: clippy 2026-03-18 18:19:03 +01:00