According to callgrind, checking kwin in release with debug symbols,
22% of cpu time in the method hasTransientInternal is spent doing
a cast to Client *, while at the begining of the method, the cast to
const Client * only uses 1.0x%.
Details
- Reviewers
graesslin - Group Reviewers
KWin - Commits
- R108:2c7b1cf76206: From 22% of cpu in hasTransientInternal to 0.2x%
The workload was just show 50 messagebox copying small files and being
unable to change the permissions.
Diff Detail
- Repository
- R108 KWin
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Very interesting finding. Any idea why that's the case?
Can go into 5.12 branch, that should be absolutely safe.
My guess is that dynamic_cast is the only type of cast that does runtime checking (see next link). Probably converting to const reduces the amount of checking.
http://gcc.gnu.org/ml/gcc/1999-12n/msg00544.html
Probably it should be safe to use static_cast that only does compile_time checks.
Can go into 5.12 branch, that should be absolutely safe.
Should it be done by cherry-pick?
Did you compare that to a profile with the updated cast?
This makes little sense and a simplified testcase doesn't measure significant differences in casting times on the wall clock time. And certainly not factor 22.
The screenshot with 22% is from the release with debug symbols from opensuse (you can see the first const cast there), the other one is from a debug build with the patch.
The 22% to 1.% is only in one method.
'key...?!
I'd assume the const casting avoids deep copies of the QList - at least that's the only explanation I could come up without a deeper investigation.
unlikely. That was my first guess as well, but the code uses const iterator, so no deep copy.
In this case I fear we cannot make it a static_cast. It could be that a ShellClient (Wayland) is a transient to Client (example: any child window KWin shows for the Client, such as Alt+F3, rules dialog, kill helper).
Can go into 5.12 branch, that should be absolutely safe.
Should it be done by cherry-pick?
We normally push to stable branch and then merge the stable branch into master.
Could you additional try qobject_cast? It is supposed to be faster than dynamic_cast and Client subclasses QObject.
I'm still new to arc.
This revision was created in a branch pointing to master, therefore when I'll do arc land, it will push into master.
How do I change the branch to land without creating a new revision?
And after landing the commit, should I do: >git checkout master, git merge <commit hash> ?