diff options
author | Chris Down <chris@chrisdown.name> | 2022-03-17 15:56:13 +0000 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2022-04-16 16:37:46 +0200 |
commit | 8806b6e2379372900e3d9e0bf6604bc7f727350b (patch) | |
tree | ae2d6c1af222db410906861f9a02da7138d1512e /dwm.c%2525253fid%2525253dd93ff48803f04f1363bf303af1d7e6ccc5cb8d3f%25253fid%25253dd93ff48803f04f1363bf303af1d7e6ccc5cb8d3f%253fid%253d8806b6e2379372900e3d9e0bf6604bc7f727350b%3fid%3d8806b6e2379372900e3d9e0bf6604bc7f727350b&id2%3dbece862a0fc4fc18ef9065b18cd28e2032d0d975?id=8806b6e2379372900e3d9e0bf6604bc7f727350b | |
parent | bece862a0fc4fc18ef9065b18cd28e2032d0d975 (diff) |
manage: propertynotify: Reduce cost of unused size hints
This patch defers all size hint calculations until they are actually
needed, drastically reducing the number of calls to updatesizehints(),
which can be expensive when called repeatedly (as it currently is during
resizes).
In my unscientific testing this reduces calls to updatesizehints() by
over 90% during a typical work session. There are no functional changes
for users other than an increase in responsiveness after resizes and
a reduction in CPU time.
In slower environments or X servers, this patch also offers an
improvement in responsiveness that is often tangible after resizing a
client that changes hints during resizes.
There are two main motivations to defer this work to the time of hint
application:
1. Some clients, especially terminals using incremental size hints,
resend XA_WM_NORMAL_HINTS events on resize to avoid fighting with the
WM or mouse resizing. For example, some terminals like urxvt clear
PBaseSize and PResizeInc during XResizeWindow and restore them
afterwards.
For this reason, after the resize is concluded, we typically receive
a backlogged XA_WM_NORMAL_HINTS message for each update period with
movement, which is useless. In some cases one may get hundreds or
thousands of XA_WM_NORMAL_HINTS messages on large resizes, and
currently all of these result in a separate updatesizehints() call,
of which all but the final one are immediately outdated.
(We can't just blindly discard these messages during resizes like we
do for EnterNotify, because some of them might actually be for other
windows, and may not be XA_WM_NORMAL_HINTS events.)
2. For users which use resizehints=0 most of these updates are unused
anyway -- in the normal case where the client is not floating these
values won't be used, so there's no need to calculate them up front.
A synthetic test using the mouse to resize a floating terminal window
from roughly 256x256 to 1024x1024 and back again shows that the number
of calls to updatesizehints() goes from over 500 before this patch (one
for each update interval with movement) to 2 after this patch (one for
each hint application), with no change in user visible behaviour.
This also reduces the delay before dwm is ready to process new events
again after a large resize on such a client, as it avoids the thundering
herd of updatesizehints() calls when hundreds of backlogged
XA_WM_NORMAL_HINTS messages appear at once after a resize is finished.
Diffstat (limited to 'dwm.c%2525253fid%2525253dd93ff48803f04f1363bf303af1d7e6ccc5cb8d3f%25253fid%25253dd93ff48803f04f1363bf303af1d7e6ccc5cb8d3f%253fid%253d8806b6e2379372900e3d9e0bf6604bc7f727350b%3fid%3d8806b6e2379372900e3d9e0bf6604bc7f727350b&id2%3dbece862a0fc4fc18ef9065b18cd28e2032d0d975?id=8806b6e2379372900e3d9e0bf6604bc7f727350b')
0 files changed, 0 insertions, 0 deletions