Bug 306384 - Toplevel::windowType() needs performance improvements
Summary: Toplevel::windowType() needs performance improvements
Alias: None
Product: kwin
Classification: Plasma
Component: core (show other bugs)
Version: 4.9.1
Platform: unspecified Linux
: NOR task (vote)
Target Milestone: 4.10
Assignee: KWin default assignee
URL: https://git.reviewboard.kde.org/r/106...
Depends on:
Reported: 2012-09-07 05:51 UTC by Martin Flöser
Modified: 2012-09-07 06:04 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 4.10
mgraesslin: ReviewRequest+


Note You need to log in before you can comment on or make changes to this bug.
Description Martin Flöser 2012-09-07 05:51:50 UTC
The call to windowType is quite in the hot code path of KWin and not really well implemented. It performs two dynamic casts just to figure out whether it's a Client or Unmanaged and has basically two different implementations interwoven in this method.

Making it a pure virtual method should quite improve the readability and performance of this method.
Comment 1 Martin Flöser 2012-09-07 06:04:05 UTC
Git commit 700bccde695f6747626295db7cba5e741a108684 by Martin Gräßlin.
Committed on 06/09/2012 at 09:09.
Pushed by graesslin into branch 'master'.

Toplevel::windowType becomes a pure virtual function

The method windowType needs actually two implementations:
* one for Clients
* one for Unmanaged

as for Clients also the window rules are checked and hacks are applied
which is both not needed for Unmanaged windows.

To have the Client specific behavior in windowType the function used to
perform two dynamic_casts which made this method one of the most
expensive during compositing, e.g. for ~1000 frames
* called ~43000 times
* ~85000 dynamic casts
* incl. cost of method: 0.24
* self cost of method: 0.05
* incl. cost of the casts: 0.12

After the change to remove the dynamic casts we have for ~1500 frames
in Client::windowType:
* called ~31000 times
* incl. cost of 0.06
* self cost of 0.02

Calls on Unmanaged and Deleted are so low that we do not need to consider
FIXED-IN: 4.10
REVIEW: 106349

M  +21   -0    kwin/client.cpp
M  +1    -0    kwin/client.h
M  +10   -0    kwin/deleted.cpp
M  +1    -0    kwin/deleted.h
M  +0    -20   kwin/toplevel.cpp
M  +1    -1    kwin/toplevel.h
M  +11   -0    kwin/unmanaged.cpp
M  +1    -0    kwin/unmanaged.h