mirror of
https://github.com/wez/wezterm.git
synced 2024-12-24 22:01:47 +03:00
wayland: reduce CPU utilization by correctly handling Refresh
On a Fedora 31 system running Wayland I noticed that wezterm and the compositor were running pretty hot on their respective CPU cores. It turned out that we had a lot of [Refresh](https://docs.rs/smithay-client-toolkit/0.6.4/smithay_client_toolkit/window/enum.Event.html#variant.Refresh) events being generated and consumed. We were treating this as needing a full paint so we'd be effectively continually running the opengl paint cycle over and over. The docs for that event say that it is intended to refresh the client decorations so let's focus it towards that instead. This does bring the CPU usage back down to intended levels. I believe this hot CPU usage to be compositor-dependent: this is the first I've seen of it out of 4 different Wayland environments!
This commit is contained in:
parent
45fe44e231
commit
0e568ea161
@ -106,7 +106,7 @@ pub struct WaylandWindowInner {
|
|||||||
#[derive(Default, Clone, Debug)]
|
#[derive(Default, Clone, Debug)]
|
||||||
struct PendingEvent {
|
struct PendingEvent {
|
||||||
close: bool,
|
close: bool,
|
||||||
refresh: bool,
|
refresh_decorations: bool,
|
||||||
configure: Option<(u32, u32)>,
|
configure: Option<(u32, u32)>,
|
||||||
dpi: Option<i32>,
|
dpi: Option<i32>,
|
||||||
}
|
}
|
||||||
@ -123,8 +123,8 @@ impl PendingEvent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event::Refresh => {
|
Event::Refresh => {
|
||||||
if !self.refresh {
|
if !self.refresh_decorations {
|
||||||
self.refresh = true;
|
self.refresh_decorations = true;
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
@ -136,8 +136,8 @@ impl PendingEvent {
|
|||||||
changed = self.configure.is_none();
|
changed = self.configure.is_none();
|
||||||
self.configure.replace(new_size);
|
self.configure.replace(new_size);
|
||||||
} else {
|
} else {
|
||||||
changed = !self.refresh;
|
changed = !self.refresh_decorations;
|
||||||
self.refresh = true;
|
self.refresh_decorations = true;
|
||||||
}
|
}
|
||||||
changed
|
changed
|
||||||
}
|
}
|
||||||
@ -469,13 +469,13 @@ impl WaylandWindowInner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.refresh_frame();
|
self.refresh_frame();
|
||||||
pending.refresh = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if pending.refresh && self.window.is_some() {
|
|
||||||
self.do_paint().unwrap();
|
self.do_paint().unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if pending.refresh_decorations && self.window.is_some() {
|
||||||
|
self.refresh_frame();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn refresh_frame(&mut self) {
|
fn refresh_frame(&mut self) {
|
||||||
if let Some(window) = self.window.as_mut() {
|
if let Some(window) = self.window.as_mut() {
|
||||||
|
Loading…
Reference in New Issue
Block a user