On KWin's composite performance, part II.

I got a bit bored this weekend (ok, ok, I had to do a lot of cleaning and so and needed an excuse) and had a look at two performance related things in KWin. First was fixing the CPU usage problem caused by using vsync, now that Thiago found out why I couldn't reproduce it (I build Qt without Glib support, it just messes the backtraces up). Interestingly it was code that was supposed to save CPU that by mistake caused the increased CPU usage. Oh well. Second improvement is unredirecting fullscreen windows - that is, if a fullscreen window is not covered by something else, such as a game or a movie, that window is excluded from compositing and allowed to draw normally. This lets it draw at the full speed and should also help with avoiding tearing. The simplest way to see this is to maximize a glxgears window and then compare its reported number of frames to also making it fullscreen using Alt+F3/Advanced/Fullscreen. I could post a video, but it would look quite similarly to the previous performance joke. This one is for real though. The small downside of unredirecting a window is that it no longer has a preview e.g. in Alt+Tab (could be handled with some more code, but not a very high priority now, unless somebody else feels like doing that or I get bored some other weekend).

This should mean that right now KWin's performance should generally match that of Compiz. Maybe a little difference here or there (I haven't really yet optimized the common paths that much), but I'm currently not aware of anything that should make a big difference. Some time back I even improved the so-called 'keep window thumbnails' functionality, which with the 'shown windows' option should match in practice what Compiz gets with viewports, i.e. previews for windows on inactive virtual desktops and fast virtual desktop switching.

So I hope people now won't have to write many rants about this or even complain about KWin to Compiz people (well, I guess I can see that as some kind of payback for them calling an internal Compiz utility 'kde-window-decorator' and making us get a load of bugreports about it :) ). Those screenshot just show increased CPU usage, i.e. the vsync bug, nothing interesting about them, except that you can't see the without logging in (really interesting that forum implementation, I mean, what kind of an idiot puts captcha on a search form?). I hope that person could be satisfied now. And, as for the KWin design flaws mentioned in the reply, I've already taken care of that:

Me (notice the evil look): You screwed up KWin's design!!!!!
Matthias: Oops, sorry, did I?

No, just kidding. KWin's design is still about the same like in KDE2.0, and, apparently, it still just works. I can't see a problem with not having been designed from the group up for compositing, something that nobody even thought about at that time, yet getting there when the time comes. I, on the other hand, think it may be interesting to watch how something that was designed that way tries to work also without. Especially if somebody at Novell decides that I get to watch that very closely (may happen, isn't life fun?). Don't think I'm bashing Compiz however, as it is a great CM, it just has a little while to go ;) (or, to put it differently, it is never a very good idea to talk about work of others and not know much about it... ).


Hurray for more performance! KWin works great for me, but top reports it as using over 50% CPU a lot of the time. Of course, I've got an Nvidia GeForce Go 7300, so that might be the reason. That's a really funny picture, btw.

By kwilliam at Mon, 08/25/2008 - 03:26

It is great to hear that Kwin has got more speed. And the "grid" plugin has got new features. Just keep the features coming so we can configure desktop how we like ;-)

Altought I couldn't find information about the window shadow. Currently it is static and when using "Magic lamp" or "Wobble" effect, the shadow does not "flex" with window but stays same sized. It makes at least those two effects ugly. I like to use the Magic lamp effect but the shadow problem makes it bad :-/

Is there fix already or coming fix? I have nVidia what still has those problems with plasma, no tweaks has helped about it :-( (But AMD just rocks and is very fast! :-D)

By fri13 at Mon, 08/25/2008 - 19:02

I finally got around installing Kubuntu 8.04 with KDE 4.1 on my laptop (Pentium M 1,4 GHz, Radeon Mobility 9000, radeon driver). And I have to say: Kwins performance is already really impressive (compared to some live cds I tried before)!! You know as soon as there is a slight peak in cpu usage, the cpu fan of my laptop starts howling. So this is a good indicator performance wise :) But it stays nicely quiet while playing with all the effects (except for the FPS monitor, uses 40%, half in each Xorg and Kwin...).

Only resizing windows, scrolling in konq or some other things really need optimization. For instance just hovering over the plugin list of e.g. Kwin effects makes the cpu go crazy. But all that doesn't seem to be Kwins fault, contrary to what I first thought. At least it also happens with all effects turned off (i.e. disabling the global effects checkbox).

Looking at how long it took compiz/beryl to become really performant on this machine, you are doing an awesome work!!! Keep it up!

By psychotron at Tue, 08/26/2008 - 12:29