Bug 163257 - Moving windows with pager active use a lot of CPU
Summary: Moving windows with pager active use a lot of CPU
Alias: None
Product: plasma4
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: Plasma Bugs List
Depends on:
Reported: 2008-06-05 11:07 UTC by FiNeX
Modified: 2008-06-09 21:56 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:

Increase update delay to decrease pager cpu usage (491 bytes, patch)
2008-06-05 22:33 UTC, Christian Mollekopf
update a single desktop (3.37 KB, patch)
2008-06-06 19:14 UTC, Marco Martin
update a single desktop ..updated (3.41 KB, patch)
2008-06-06 19:45 UTC, Marco Martin

Note You need to log in before you can comment on or make changes to this bug.
Description FiNeX 2008-06-05 11:07:17 UTC
Version:           Revision 816682 (using Devel)
Installed from:    Compiled sources
OS:                Linux

I've noticed that if the pager is active, plasma use about 30-40% of CPU when I quickly move windows. I'm using 4 desktop and twinview with nvidia drivers.

I've closed the pager widget and the CPU use is less than 2% when moving windows.

Probably repainting the windows on the pager consume too much CPU.
Comment 1 Marco Martin 2008-06-05 12:51:01 UTC
to me it usually the cpu doesn't go so high, but the problem seems to exists.
the problem doesn't seem to be in the paint stuff rather than in recalculateWindowRects()
the problem is that when a window moves all the window geoms for all desktops are calculated again from scratch..
Comment 2 FiNeX 2008-06-05 13:34:29 UTC
I've noticed that resizing a window, doesn't use so much CPU, it use about 15-20% of CPU.
Comment 3 Aaron J. Seigo 2008-06-05 20:58:17 UTC
yes, each desktop area should be painted independantly. this will result in smaller repaints, and was how we did it in kde3.

calculating window geoms is cheap, painting is not.
Comment 4 Christian Mollekopf 2008-06-05 22:33:48 UTC
Created attachment 25143 [details]
Increase update delay to decrease pager cpu usage

I dont have a clue how to solve this problem properly. Somebody has to find out
how to check which windows were changed. As a quick fix I have just increased
the update delay to 1 sec. This way i just uses up to 2% for me.
Comment 5 Marco Martin 2008-06-05 23:47:50 UTC
aaron: hmm, but paintinterface always gets the whole applet rect, is there a wai to repaint only a piece without having the rest erased? i tried that but the other desktops always gets totally black

christian: i would use this anyways, i see that half a second decreases the usage very much already...
Comment 6 Aaron J. Seigo 2008-06-06 00:18:00 UTC
.5s makes it look completely jumpy, as if it can't keep up for some reason. not good.

> is there a wai to repaint only a piece without having the rest erased

void QGraphicsItem::update ( const QRectF & rect = QRectF() )

which implies doing some bookkeeping in pager to tell which desktop needs repainting.

the Easy(tm) way is to make each desktop a separate QGraphicsItem, really.
Comment 7 Marco Martin 2008-06-06 19:14:50 UTC
Created attachment 25166 [details]
update a single desktop

don't know if i got this right: the desktop where the window changed tracked by
m_dirtyDesktop and then the update done only on his rect
Comment 8 Marco Martin 2008-06-06 19:45:29 UTC
Created attachment 25167 [details]
update a single desktop ..updated

oh, kwindowinfo::desktop() seems to return -1 sometimes that caused crashes,
this adds more checks
Comment 9 Daniel Laidig 2008-06-07 16:09:52 UTC
I don't think the current patch will work with windows that are on all desktops.
Comment 10 Aaron J. Seigo 2008-06-09 01:34:42 UTC
no, this will work just fine with windows on all desktops. such windows return -1 (or, more properly, NET::OnAllDesktops, which is defined as -1) and so this will set the value of dirty desktop to -1 and update the entire pager (which is correct).

Marco: looks good.
Comment 11 FiNeX 2008-06-09 12:50:10 UTC
I've just recompiled KDE, now moving windows make plasma use not more than 25% of CPU, but only for some istants... the performance is improved since some days ago. 
Comment 12 Marco Martin 2008-06-09 21:56:42 UTC
SVN commit 818842 by mart:

keep track in what desktop a window was moved and repaint only that
raise the update interval to half a second
these two things saves a lot of cpu
BUG: 163257

 M  +30 -2     pager.cpp  
 M  +1 -0      pager.h  

WebSVN link: http://websvn.kde.org/?view=rev&revision=818842